Filter löschen
Filter löschen

Webwrite to metadata Thingspeak Channel

4 Ansichten (letzte 30 Tage)
Marc Hanssens
Marc Hanssens am 26 Jun. 2024
Kommentiert: Marc Hanssens am 9 Jul. 2024
Helllo,
I would like to write to the Metadat of my channel but I cna't get it to work. as a test , I tried wiriting to the Status which works.
if fieldName = "status"; is changed to fieldName = "metadata"; it doesn't work! does anyone know the trick for getting this to work?
code here:
%keys & ID here ...
thingSpeakURL = "http://api.thingspeak.com/";
thingSpeakWriteURL = thingSpeakURL + "update";
fieldName = "status";
fieldValue = '[100 100 100 92 93 93 94 ; 55 55 56 57 58 63 64 ; 333 444 555 666 777 888 999]';
response = webwrite(thingSpeakWriteURL,"api_key",writeApiKey,fieldName,fieldValue);
  1 Kommentar
Marc Hanssens
Marc Hanssens am 9 Jul. 2024
Hello all, I finally worked this out and here is my solution showing how to writethe word "meta" to the metadata setting:
where CHANNELID is your channel ID and USERKey is you user key -not the channel read or write key.
url = 'https://api.thingspeak.com/channels/CHANNELID.json?api_key=USERKey';
options = weboptions('MediaType','application/x-www-form-urlencoded','RequestMethod','put');
response = webwrite(url,"metadata","meta",options);
display(response);

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Piyush Kumar
Piyush Kumar am 26 Jun. 2024
"Metadata" is one of the channel properties. You can change your channel properties on the My Channels page in the Channel Settings tab. You can also use the REST API to Write Settings.
If you are using REST API to write settings, the URL format should be like this - https://api.thingspeak.com/channels/<channel_id>.<format>
You can go through these links for more details -
If you want to update channel data using REST API, the URL format should be like this - https://api.thingspeak.com/update.<format>
  1 Kommentar
Marc Hanssens
Marc Hanssens am 27 Jun. 2024
Hello PK,
Thanks for your response. The above code that I have supplied shows the actual working code for updating a Channel's Status. We can almost consider Status of a channel as a 9th field as you can update the fields and status all in one call and it inserts a channel entry in doing so. The question is, given the current code that I have, I wish to update the Metadata of a channel via WebWrite(or similar mechanism).This would not create a new entry to our channel but update the Metadata. Why would I want to do so you might ask? I would like to put some channel related information in the Metadata a bit like a status but I wish to have it at a channel level not at a feeds level.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Configure Accounts and Channels finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by