# HttpPost Error 400

**URL:** <https://forum.inductiveautomation.com/t/httppost-error-400/18719>\
**Category:** Ignition\
**Created:** [July 4, 2018, 10:28am UTC](https://forum.inductiveautomation.com/t/httppost-error-400/18719 "2018-07-04T10:28:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![oisin.gribben](https://avatars.discourse-cdn.com/v4/letter/o/9d8465/32.png) [@oisin.gribben](https://forum.inductiveautomation.com/u/oisin.gribben)\
**Post date:** [July 4, 2018, 10:28am UTC](https://forum.inductiveautomation.com/t/httppost-error-400/18719/1 "2018-07-04T10:28:27Z")

</div>

I’ve tried to convert from urllib2 to system.net.httpPost.  
When placing all my vlaues in the function I get this error. The URL works with the urllib2 but not with httpPost

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/54c9c46408deab39bb0f4eb2eb0909358ec661ff.png)

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/c0f734a4b70e26b97575d29232ea98e5896248c0.png)

---

<div class="post-metadata">

**Author:** ![R.Alamsha](https://avatars.discourse-cdn.com/v4/letter/r/e5b9ba/32.png) [@R.Alamsha](https://forum.inductiveautomation.com/u/R.Alamsha)\
**Post date:** [July 4, 2018, 12:18pm UTC](https://forum.inductiveautomation.com/t/httppost-error-400/18719/2 "2018-07-04T12:18:29Z")

</div>

Try this.

> # HTTP POST

> params = {'test1': 1, '10000': 2, '500000': 3}  
> res1 = system.net.httpPost("[https://postman-echo.com/post](https://postman-echo.com/post)", params)  
> res2 = system.net.httpPost("[http://httpbin.org/post](http://httpbin.org/post)", params)

> print res1,  
> print res2

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 5, 2018, 3:19pm UTC](https://forum.inductiveautomation.com/t/httppost-error-400/18719/3 "2018-07-05T15:19:53Z")

</div>

HTTP code 400 means a bad request, which most likely means something’s malformed or unexpected in the JSON payload you’re sending the server. Do you have an example of a ‘good’ API call? Have you tried using something like [postman](https://www.getpostman.com/) to manually test against the API? Have you used Wireshark or a generic HTTP server to check the packet being sent from Ignition to compare it against a good API call?

---

<div class="post-metadata">

**Author:** ![oisin.gribben](https://avatars.discourse-cdn.com/v4/letter/o/9d8465/32.png) [@oisin.gribben](https://forum.inductiveautomation.com/u/oisin.gribben)\
**Post date:** [July 5, 2018, 3:31pm UTC](https://forum.inductiveautomation.com/t/httppost-error-400/18719/4 "2018-07-05T15:31:31Z")

</div>

I’ve tried the postman method and it works. I also have it working to the same API only using urllib2. I transferred over the same post data to the httpPost and that’s when the 400 error started happening.

Would it be an issue with the order of the httpPost parameters that is affecting it.  
This is the format I have tried it in.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/1/13e280e9fa7289947b33d2cefdc0853e4ec27f5c.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 5, 2018, 3:40pm UTC](https://forum.inductiveautomation.com/t/httppost-error-400/18719/5 "2018-07-05T15:40:21Z")

</div>

Using keyword arguments the order shouldn’t matter. I would check a good vs bad API request in Wireshark if you want to find out what’s wrong - although, if urllib2 was working, I’m not sure why you’re going through the effort to switch over.

---

<div class="post-metadata">

**Author:** ![oisin.gribben](https://avatars.discourse-cdn.com/v4/letter/o/9d8465/32.png) [@oisin.gribben](https://forum.inductiveautomation.com/u/oisin.gribben)\
**Post date:** [July 5, 2018, 3:47pm UTC](https://forum.inductiveautomation.com/t/httppost-error-400/18719/6 "2018-07-05T15:47:10Z")

</div>

I wanted to use the functions recommended in the ignition manual. I only then resorted to urllib2 to see if was an issue with our API or not.

---

<div class="post-metadata">

**Author:** ![Trent.Boudreaux](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/trent.boudreaux/32/4138_2.png) [@Trent.Boudreaux](https://forum.inductiveautomation.com/u/Trent.Boudreaux)\
**Post date:** [July 5, 2018, 4:18pm UTC](https://forum.inductiveautomation.com/t/httppost-error-400/18719/7 "2018-07-05T16:18:41Z")

</div>

Have you tried using keyword arguments?

system.net.httpPost(url=url,contentType=“application/json”,postData=postData,connectTimeout=10000,readTimeout=30000,username=“admin”,password=“Admin1234”)

---

<div class="post-metadata">

**Author:** ![oisin.gribben](https://avatars.discourse-cdn.com/v4/letter/o/9d8465/32.png) [@oisin.gribben](https://forum.inductiveautomation.com/u/oisin.gribben)\
**Post date:** [July 5, 2018, 4:20pm UTC](https://forum.inductiveautomation.com/t/httppost-error-400/18719/8 "2018-07-05T16:20:42Z")

</div>

yes I thought that’s what the issue was at first but I still get the same issue.
