MATLAB: Thingspeak, Delete channel with HTTP DELETE, webwrite

401delete channelhttp deleteMATLABThingSpeakunauthorizedwebwrite

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?

Best Answer

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);