# POST request stopped working. Why?

**URL:** <https://community.particle.io/t/post-request-stopped-working-why/44930>\
**Category:** Troubleshooting\
**Created:** [November 1, 2018, 6:47pm UTC](https://community.particle.io/t/post-request-stopped-working-why/44930 "2018-11-01T18:47:01Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![kanurys](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/kanurys/32/4607_2.png) [@kanurys](https://community.particle.io/u/kanurys)\
**Post date:** [November 1, 2018, 6:47pm UTC](https://community.particle.io/t/post-request-stopped-working-why/44930/1 "2018-11-01T18:47:01Z")

</div>

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:

```auto
var requestURL = "https://api.particle.io/v1/devices/" + deviceID + "/" + web_com + "/";
$.post( requestURL, { params: message, access_token: accessToken });

```

What changed and what am I missing here?

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [November 1, 2018, 6:58pm UTC](https://community.particle.io/t/post-request-stopped-working-why/44930/2 "2018-11-01T18:58:19Z")

</div>

Could you show us the error message as well?

---

<div class="post-metadata">

**Author:** ![kanurys](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/kanurys/32/4607_2.png) [@kanurys](https://community.particle.io/u/kanurys)\
**Post date:** [November 1, 2018, 7:01pm UTC](https://community.particle.io/t/post-request-stopped-working-why/44930/3 "2018-11-01T19:01:03Z")

</div>

This prints out with the error symbol to the left.

POST [https://api.particle.io/v1/devices/](https://api.particle.io/v1/devices/)" Device ID "/web\_com/ 400

---

<div class="post-metadata">

**Author:** ![kanurys](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/kanurys/32/4607_2.png) [@kanurys](https://community.particle.io/u/kanurys)\
**Post date:** [November 1, 2018, 7:06pm UTC](https://community.particle.io/t/post-request-stopped-working-why/44930/4 "2018-11-01T19:06:27Z")

</div>

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/](http://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

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [November 1, 2018, 7:21pm UTC](https://community.particle.io/t/post-request-stopped-working-why/44930/5 "2018-11-01T19:21:44Z")

</div>

Would you mind posting a Screenshot of those errors? That’s often more descriptive.

---

<div class="post-metadata">

**Author:** ![kanurys](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/kanurys/32/4607_2.png) [@kanurys](https://community.particle.io/u/kanurys)\
**Post date:** [November 1, 2018, 7:28pm UTC](https://community.particle.io/t/post-request-stopped-working-why/44930/6 "2018-11-01T19:28:16Z")

</div>

yeah, sorry. One moment…

---

<div class="post-metadata">

**Author:** ![kanurys](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/kanurys/32/4607_2.png) [@kanurys](https://community.particle.io/u/kanurys)\
**Post date:** [November 1, 2018, 7:33pm UTC](https://community.particle.io/t/post-request-stopped-working-why/44930/7 "2018-11-01T19:33:03Z")

</div>

This error comes up when I click a button that currently says “OFF”

 ![error_screenshot](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/0/9/090af45f28c0cb2577a8e7a1c3728a329fa647e7.png)

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [November 1, 2018, 9:56pm UTC](https://community.particle.io/t/post-request-stopped-working-why/44930/9 "2018-11-01T21:56:14Z")

</div>

Does your web page load a specific version of JQuery?

I have seen this type of error before and what happened was that JQuery 1.3.2 was no longer available and you would need to update to a newer version.

---

<div class="post-metadata">

**Author:** ![kanurys](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/kanurys/32/4607_2.png) [@kanurys](https://community.particle.io/u/kanurys)\
**Post date:** [November 4, 2018, 8:15pm UTC](https://community.particle.io/t/post-request-stopped-working-why/44930/10 "2018-11-04T20:15:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kanurys](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/kanurys/32/4607_2.png) [@kanurys](https://community.particle.io/u/kanurys)\
**Post date:** [December 10, 2018, 11:43pm UTC](https://community.particle.io/t/post-request-stopped-working-why/44930/11 "2018-12-10T23:43:28Z")

</div>

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.

What changed to make it act up again?

 ![error_screenshot](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/e/0/e0810d94f12daa09b7a638284800b0fb545ea8ae.png)

```auto
<!DOCTYPE HTML>
<html>
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    </head>
    
    
    <button id="controlstate1" onclick="web_communication('A', 'C', '-1')" style="height:33px; width:80px; font-size:23px; cursor: pointer;">Toggle</button>
    
    
    <script type="text/javascript">
			
		//particle core related stuff (global)
		var deviceID = "1234567890";
		var accessToken = "abcdefghijklmn";
        
        function web_communication(tank, action, new_value){
                        var message = tank + action + new_value;
                        
                        //send the command to the Particle Core
                        var requestURL = "https://api.particle.io/v1/devices/" + deviceID + "/" + "web_com" + "/";
                            $.post( requestURL, { params: message, access_token: accessToken });
                    }
    </script>    
</html>

```

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [December 11, 2018, 4:35am UTC](https://community.particle.io/t/post-request-stopped-working-why/44930/12 "2018-12-11T04:35:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kanurys](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/kanurys/32/4607_2.png) [@kanurys](https://community.particle.io/u/kanurys)\
**Post date:** [December 20, 2018, 7:17pm UTC](https://community.particle.io/t/post-request-stopped-working-why/44930/13 "2018-12-20T19:17:59Z")

</div>

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.

Thanks again…

---

<div class="post-metadata">

**Author:** ![nrobinson2000](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/nrobinson2000/32/15624_2.png) [@nrobinson2000](https://community.particle.io/u/nrobinson2000)\
**Post date:** [December 20, 2018, 7:24pm UTC](https://community.particle.io/t/post-request-stopped-working-why/44930/14 "2018-12-20T19:24:20Z")

</div>

There are a few Chrome Extensions that should fix the CORS problem.

Here is the one I use:

> **[Allow-Control-Allow-Origin: \*](https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi)**
>
> Allows to you request any site with ajax from any source. Adds to response 'Allow-Control-Allow-Origin: \*' header
