I have an old Core running the same program for a few years now. My web page code uses javascript to send POST requests to control the core. This has worked flawlessly for a few years. Today it gives a 400 error in the browser debug console. Here is my code that worked for a long time:
Ah, the first time I click a button on the web page and the error is thrown I see to the right of the above error: api.particle.io/v1/devices/" Device ID "/web_com/:1
The second time and successive times I click the button, I see this to the right of the error:
jquery.min.js:19
Thank you for your suggestion. This seemed to fix the problem. I was referencing an outdated JQuery. I updated to the current version 3.3.1 and it seems to be working great.
Well, I updated the JQuery version as noted, and it worked for over a month. Nothing has changed, but a similar error cropped up two days ago. Below is the error and some bare-bones code that is throwing it.
I’m not sure–that version of jquery is the current version. Google no longer recommends the type="text/javascript" charset="utf-8" part but I don’t think it is hurting you.
You do not need that trailing “/” on the requestURL, but I believe that still works with it.
Have you checked your real access token and device ID for typos?
What browser is that? I would try Chrome or Firefox first and if you already using one of those two, try the other. If you are hosting this, what CORS policy does your host allow?
Thanks for the analysis. The browser is Chrome. Token and device ID are correct. I’ll clean up the type and charset stuff and see if it makes a difference.
I’m not very familiar with CORS, but from my reading, it seems that is a possible failure point of this code. I’ll look into it.