Thingspeak, Delete channel with HTTP DELETE, webwrite
9 ビュー (過去 30 日間)
古いコメントを表示
Julius Kübler
2020 年 2 月 5 日
編集済み: Christopher Stapels
2021 年 1 月 28 日
Hey there,
I want to delete a thingspeak channel using the webwrite function. This is what it looks like:
url = ['https://api.thingspeak.com/channels/' channelID '.json']
options = weboptions('RequestMethod','delete', 'MediaType','application/x-www-form-urlencoded');
response = webwrite(url,'api_key',userAPIkey,options)
This returns status 401 Unauthorized. But if I only change the RequestMethod to 'put', I don't get any errors. But using 'put' only allows me to change the channel settings. How do I delete the channel using webwrite?
0 件のコメント
採用された回答
Christopher Stapels
2020 年 2 月 6 日
Make the api_key a querry string parameter.
url = ['https://api.thingspeak.com/channels/' channelID '.json?api_key=<userAPIKey>']
options = weboptions('RequestMethod','delete');
response = webwrite(url);
3 件のコメント
Javier Garcia Montano
2020 年 12 月 4 日
Still returning status 401
HELP!! D:
My code:
channelID = "..."
userAPIkey = "..."
url = ['https://api.thingspeak.com/channels/' channelID '.json?api_key=<userAPIkey>']
options = weboptions('RequestMethod','delete', 'MediaType','application/x-www-form-urlencoded');
response = webwrite(url,'api_key',userAPIkey,options)
Christopher Stapels
2021 年 1 月 28 日
編集済み: Christopher Stapels
2021 年 1 月 28 日
I was just using this code and I think this is more robust. I got extra characters when I used the above.
url = sprintf('https://dev1-web.thingspeak.com/channels/%d.json?api_key=%s',channelID,userAPI);
options = weboptions('RequestMethod','delete', 'MediaType','application/x-www-form-urlencoded');
response = webwrite(url,options)
but make sure channelID is a number, not a string. (no quotes)
その他の回答 (0 件)
コミュニティ
その他の回答 ThingSpeak コミュニティ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!