Andrew Clark in Discussions
최근 활동: 2023년 2월 2일

Hello, I need help with a simple example. I am trying to do a simple bulk update using JSON & Javascript, using this parm, header and body: $.post("https://api.thingspeak.com/channels/xxxxxxxxx/bulk_update.json" ,{ "Content-Type": "application/json", "write_api_key" : "xxxxxxxxxxxxxxxx", "updates": [ { "created_at": "2022-12-30 10:26:2 -0800", "field1": 100, "status": "good" }, { "created_at": "2022-01-12 10:27:2 -0800", "field2": 100, "field3": 200, "field5": 600, "latitude": 123, "longitude": 23, "elevation": 34 }], function(data){ console.log(data) // log anything returned to the console } }); When I run the above (Mac OS, Chrome) I receive this error message: Access to XMLHttpRequest at 'https://api.thingspeak.com/channels/1283582/bulk_update.json' from origin 'https://backpaqlabs.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. api.thingspeak.com/channels/1283582/bulk_update.json:1 Failed to load resource: net::ERR_FAILED Is there something wrong with the syntax or JSON payload? I have literally taken it from the example in the doc, so I assume it should comply with the API endpoint. BTW, I am receiving CORS errors with getJSON as well, also from Javascript/Chrome. Appreciate any help. Thanks! Still getting CORS error with Bulk Update I think the browser route is specifically denied in the CORS policy on purpose. Ill see what else I can find out. Hi Christopher, thanks for the response. Javascript, which runs in browsers such as Chrome, is allowed, and I use it extensively to fetch data (ie, READ) from Thingspeak. The issue seems to be with WRITE/UPDATE, as all of my READ API functions are currently working. My question is concerning the WRITE function and what seems to be blocking my API calls on your server/endpoint. Can you please verify that UPDATE API requests (and specifically, BULK UPDATE) from outside THINGSPEAK.COM domain are allowed by your CORS policy to access the Thingspeak servers? Thanks much! The dev team agrees with you that bulk update via browser is not specifically prohibited in our policy. You should also have the header 'Access-Control-Allow-Origin' with the value set to *. Do you have this in your request? Christopher, thanks for the tip. Unfortunately, same result using 'Access-Control-Allow-Origin' : '*' in the request Header. I was able to get the "non-bulk" request to work, that is, "update.json". So it seems it's something specific to Bulk. I am also wondering if it could be something in the JSON body that's triggering the error...is the JSON syntax somehow position sensitive, ala Python (in other words, are invisible blanks or tabs a problem in the JSON?) Thanks! Hi Christopher, need to bump this Q as i am still unable to perform the Bulk Updates using JSON due to CORS errors. Can you please confirm with development that I should be able to do the bulk method as described in the above example? Thanks much! I tried out your code and I think this is not a ThingSpeak issue. If I change the URL to anything, I still get the error. Ill keep plugging though. Hi Christopher, thanks for taking a look! It may not be a Thingspeak issue per se, but may be something to do with how the JSON request is formatted or specified. I have tested the JSON and it's semantically correct and correctly formatted. To me, it's still a Thingspeak issue if simple Update API requests will not work or are so hard to use that users will give up. As has been mentioned several times prior, it would be great if we could do this request from the Library API or some other easier-to-use method. Thanks! bulk update json javascript cors
Trevor Furlong in Discussions
최근 활동: 2021년 5월 14일

Hello From earlier today a project i've been working on has stopped working. It was working for the last couple of weeks with no coding updates in the mean time. The error i'm only now getting is "from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource." Im transferring four readings from thingspeak to a web page the get command i'm using is. xhttp.open("GET", "https://api.thingspeak.com/channels/752230/feeds/last", false); xhttp.send(); Why would i only start receiving this error today. If more information is needed i will send it on. any insights would be much appreciated. Thanks Trev starting to get ERROR : blocked by CORS policy We are aware of this issue and are working on a fix. Thank you for letting us know. A server-side configuration change has resulted in a XHR requests to ThingSpeak being blocked at the browser (i.e., ThingSpeak servers do not even see the request). You can confirm that the requests still work by making them from a different client - like cURL or POSTMAN. A fix is being worked on and we anticipate it being released shortly. thanks for the quick response Thanks - I am also getting this problem which started yesterday as far as I can tell (using highstockchart to retrieve data, this was working 2 days ago) Same problem. Using highstock chart from two days i receive error while trying getJSON request. Just letting you know our web Dashboard is down since this CORS issue came about. Thanks Christopher - glad to hear a fix is in progress. I'm seeing the same problem from my ThingSpeak plugin: Access to XMLHttpRequest at 'https://api.thingspeak.com/channels/8203/feeds.json?days=2' from origin 'https://thingspeak.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. best regards, Tony I apologize for the disruption. The fix should be in place later today. Thanks for the update. This is resolved. If anyone is still seeing issues, please reply to this response. I'm still getting the "CORS Missing Allow Origin" error on the URL https://thingspeak.com/channels/[channelid]/feed.json Change the url from https://ThingSpeak.com/... To https://api.thingspeak.com/... Thanks! It's fine now. Vinod, yes I am still being this same issue. API calls had been working for 6 months and suddenly I am receiving CORS errors. Here is what I am getting: <</matlabcentral/discussions/uploaded_files/4670/data>> Please let me know when this will be fixed for my example. Thanks! Do yo see this if you use a fresh browser and sign out and then back in? Make sure you close all other browsers signed in to MathWorks. Hi yes, I always flush the cache and believe I have only one browser open at a time. I now am able to get the API to work if I use a getJSON call rather than fetch. Is this issue really fixed? I have this simple HTML app that makes a request to 'feeds.json': https://github.com/rnswamy1954/Hello-World/blob/master/index.html#L126 I can make the exact same request from CURL/POSTMAN/browser-url and I get the response properly. But when am trying to load my HTML page, I get response with status = 0 and type = opaque As you can see, my request is going to api.thingspeak And I do have 'no-cors' in my request header. Any help will be greatly appreaciated Will appreciate an early response.... I'm not able to reproduce the issue. As you can see below, many users have confirmed the issue has been resolved a while back. Out of curiosity, I look at <https://github.com/rnswamy1954/RNS_ThingSpeak/blob/Master/index.html#L38 this file> and see that your timeout is 10 seconds. With a free account, your channel can only be updated every 15 seconds. Can you help me understand why you need to poll ThingSpeak every 10 seconds? Yes - the issue was resolved a while back. Many users have confirmed it on this thread. If you are still experiencing it, you may need to clear your browser cache and reload your page. I look at <https://github.com/rnswamy1954/RNS_ThingSpeak/blob/Master/index.html#L38 this file> and see that your timeout is 10 seconds. With a free account, your channel can only be updated every 15 seconds. Can you help me understand why you need to poll ThingSpeak every 10 seconds? Apart from frequent polling, there were couple of issues which have been sorted. Now, it is working fine! Thank you very much for your support!! thingspeak http request cors

ThingSpeak 정보

The community for students, researchers, and engineers looking to use MATLAB, Simulink, and ThingSpeak for Internet of Things applications. You can find the latest ThingSpeak news, tutorials to jump-start your next IoT project, and a forum to engage in a discussion on your latest cloud-based project. You can see answers to problems other users have solved and share how you solved a problem.