Thingspeak, Delete channel with HTTP DELETE, webwrite
9 views (last 30 days)
Show older comments
Julius Kübler
on 5 Feb 2020
Edited: Christopher Stapels
on 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 Comments
Accepted Answer
Christopher Stapels
on 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 Comments
Javier Garcia Montano
on 4 Dec 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
on 28 Jan 2021
Edited: Christopher Stapels
on 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)
More Answers (0)
Communities
More Answers in the ThingSpeak Community
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!