Thingspeak, Delete channel with HTTP DELETE, webwrite
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Julius Kübler
am 5 Feb. 2020
Bearbeitet: Christopher Stapels
am 28 Jan. 2021
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 Kommentare
Akzeptierte Antwort
Christopher Stapels
am 6 Feb. 2020
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 Kommentare
Javier Garcia Montano
am 4 Dez. 2020
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
am 28 Jan. 2021
Bearbeitet: Christopher Stapels
am 28 Jan. 2021
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)
Weitere Antworten (0)
Communitys
Weitere Antworten in ThingSpeak Community
Siehe auch
Kategorien
Mehr zu ThingSpeak 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!