Thingspeak, Delete channel with HTTP DELETE, webwrite

9 ビュー (過去 30 日間)
Julius Kübler
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?

採用された回答

Christopher Stapels
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
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
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 コミュニティ

カテゴリ

Help Center および File ExchangeThingSpeak についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by