필터 지우기
필터 지우기

Webwrite to metadata Thingspeak Channel

조회 수: 4 (최근 30일)
Marc Hanssens
Marc Hanssens 2024년 6월 26일
댓글: Marc Hanssens 2024년 7월 9일
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
Marc Hanssens
Marc Hanssens 2024년 7월 9일
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);

댓글을 달려면 로그인하십시오.

답변 (1개)

Piyush Kumar
Piyush Kumar 2024년 6월 26일
"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
Marc Hanssens
Marc Hanssens 2024년 6월 27일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Configure Accounts and Channels에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by