Thingspeak.com yelling "getJSON request failed!"

Hello
I'm using site Thingspeak.com for storing data from my sensors.
Aprox 2 days ago it apear the error message:
I can not use any more: "getJSON request failed!"
$.getJSON('https://api.thingspeak.com/channels/'+channelNumber+'/feed.json?&offset=0&results=2500;key='+key, function(data)
It is not about cookies, because even in private windows I get same error.
Firefox in debug windows yelling:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.thingspeak.com/channels/795411/feed.json?&offset=0&results=2500;key=Z67C5TON0V5UU0M6. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
My script worked till now, and I didn't change nothing on it. This errpr does not depent on browser.
What I need to change to be able to use again?
Thx

 Akzeptierte Antwort

Vinod
Vinod am 15 Apr. 2021

0 Stimmen

The underlying issue has been fixed. A missing response header from the server caused your browser to not make any XHR requests.
Can you confirm your code is working again?

12 Kommentare

Isidor Pol
Isidor Pol am 15 Apr. 2021
Woow.
Thank you for quick respond.
Yes it working!
Only what I can notice that now tohe loding of graph is aprox 50% slower than it was.
Os it posible?
Vinod
Vinod am 15 Apr. 2021
The slowness is likely unrelated to changes on our end.
Isidor Pol
Isidor Pol am 15 Apr. 2021
Anyway..thank you for fixing!
R W
R W am 16 Apr. 2021
Had the same problem and it is now working again.
Thank you for fixing!
I don't believe this is fixed for me. Just started receiving the same CORS-related errors and have tried with both Safari and Chrome (which is fully CORS enabled.) Here's what I get:
Please advise when this will be fixed. Thanks.
Vinod
Vinod am 22 Apr. 2021
Can you provide a link to your site or provide the HTML code that reproduces the issue, Andrew?
Hi Vinod, here is a link to the application but I can't really provide a simplified HTML code just now:
Go to: http://www.backpaqlabs.com/sycndcharts4xaqizz.html and use the following user data:
BackpAQ Name: BP2-EPA
Start Date: 4/1/21 (pick date on calendar)
End Date: 4/21/21 (pick date on calendar)
Once you enter the second date the data should display in both the map and the graph. They fail due to the CORS error, which may be viewed in the console. Thanks again!
Drew
Isidor Pol
Isidor Pol am 22 Apr. 2021
It is imposible for me to set the date.
Hi..you have to use the calendar date picker, not enter an actual date. You just click in the box and a calendar month will show. Then, click on April 1 for start date and April 21 for end date. Thanks,
Andrew Clark
Andrew Clark am 22 Apr. 2021
Bearbeitet: Andrew Clark am 23 Apr. 2021
Vinod, here is some minimal HTML code that shows the CORS error. I am using fetch which is the more modern replacement for XHR-type calls. This code has been working great until this week. If I execute the API call from the browser (or CURL) it succeeds, so I know the Thingspeak data is ok. And it fails using the regular jQuery "$.getJSON(" calls as well. Did Thingspeak somehow lose the "alllow CORS" in the response header? See https://stackoverflow.com/questions/67101121/no-access-control-allow-origin-thingspeak for more examples of this fail.
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<title>BackpAQ Track Search</title>
<meta name="author" content="Andrew Clark">
</head>
<body>
<script>
//var startDate =
//var endDate =
var bpChannel = "1278482"; // public channel
const unitsPM = "µg/m³";
// fetch the (selected) data from ThingSpeak
function loadData() {
var result;
// prototype: fetch('https://api.thingspeak.com/channels/1278482/feeds.json?api_key=xxxxxxxxxxxx&results=100' ,{
fetch('https://api.thingspeak.com/channels/' + bpChannel + '/feed.json?results=2000&timezone=America%2FLos_Angeles', {
method: 'GET', // or 'PUT'
headers: {
'Content-Type': 'application/json',
},
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
var jParse = JSON.stringify(data, null, 2); // parse and pretty
console.log(jParse);
})
.catch((error) => {
console.error('Error:', error);
});
} // loadData
loadData(); // go fetch
</script>
</body>
</html>
Vinod
Vinod am 23 Apr. 2021
Thanks for the HTML. I'm able to reproduce the issue with this. I believe in certain cases the required header is not being added at the server end. We'll look into this and provide resolution shortly.
Andrew Clark
Andrew Clark am 23 Apr. 2021
OK thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Communitys

Weitere Antworten in  ThingSpeak Community

Kategorien

Mehr zu Write Data to Channel finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

am 15 Apr. 2021

Kommentiert:

am 23 Apr. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by