Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Team

I am creating an email using Matlab Analysis to my Thingspeak channel. Now i am getting this error "
Specify a valid read API key, or make the channel public to avoid specifying the read API key.
". My channel is set to private for now and dont want to change it to public channel. What could be the reason for this error?

Create an email alert with HTTP POST - MATLAB Send Alert[^]

What I have tried:

data = thingSpeakRead(941028, "NumMinutes", 100);
aveTemp = mean(data(:,7));
apiKey = 'PFZRTJ2JYTXW519I';
alertURL = "https://api.thingspeak.com/alerts/send";
options = weboptions("HeaderFields",["ThingSpeak-Alerts-API-Key", apiKey]);
alertBody = sprintf("The temperature is %0.2fF.", aveTemp);

if avg_temperature > 60.0
    webwrite(alertURL, "body", alertBody, "subject", alertSubject, options);
end
Posted
Updated 13-Jan-20 2:46am
v2
Comments
Richard MacCutchan 13-Jan-20 4:35am    
The message is telling you what you need to do.
gcogco10 13-Jan-20 4:51am    
Hi mate, i changed the channel to public and was not getting that error anymore.

1 solution

As mentioned in the error, you either need to access it with a Read API key or make it public. From the comments, it sounds like you made it public.
 
Share this answer
 
Comments
gcogco10 13-Jan-20 8:47am    
@ZurdoDev, I did made it public and I am no longer getting that error.
ZurdoDev 13-Jan-20 8:49am    
But that also means it's public now, which you may or may not want. Your decision.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900