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
채택된 답변
Vinod
2021년 4월 15일
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
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
2021년 4월 15일
The slowness is likely unrelated to changes on our end.
Anyway..thank you for fixing!
R W
2021년 4월 16일
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
2021년 4월 22일
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:
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
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
2021년 4월 22일
편집: Andrew Clark
2021년 4월 23일
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
2021년 4월 23일
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.
OK thanks!
추가 답변 (0개)
커뮤니티
더 많은 답변 보기: ThingSpeak 커뮤니티
카테고리
도움말 센터 및 File Exchange에서 Write Data to Channel에 대해 자세히 알아보기
제품
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
