# HttpPost response 400 error

**URL:** <https://forum.inductiveautomation.com/t/httppost-response-400-error/57821>\
**Category:** Ignition\
**Created:** [March 30, 2022, 3:29pm UTC](https://forum.inductiveautomation.com/t/httppost-response-400-error/57821 "2022-03-30T15:29:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Staffan\_William-Olss](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@Staffan\_William-Olss](https://forum.inductiveautomation.com/u/Staffan_William-Olss)\
**Post date:** [March 30, 2022, 3:29pm UTC](https://forum.inductiveautomation.com/t/httppost-response-400-error/57821/1 "2022-03-30T15:29:35Z")

</div>

I'm trying make a httpPost to get some information from another system. The problem is that i get a http response 400 that indicates that the body (post data) is not fomated correctly. The code looks like this:

> Blockquote  
> url = "[http://endpoint](http://endpoint) for deviations/get?fromDate="+str(formatedFromDate)+"&toDate="+str(formatedToDate)  
> body = {  
> "equipmentIds" : "[100000511]",  
> "statusIds": "[100]"   
> }  
> header = {  
> "Authorization": "Bearer "+token  
> }   
> deviations = system.net.httpPost(url,"application/json",body,10000,60000,"","",header,0,0)  
> Blockquote

The error that I get follow like this:  
{u'traceId': '|7d3ea763-40c9dd92084bf386.', u'type': '[RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content](https://tools.ietf.org/html/rfc7231#section-6.5.1)', u'title': 'One or more validation errors occurred.', u'errors': {u'$': ['''' is an invalid start of a property name. Expected a '"'. Path: $ | LineNumber: 0 | BytePositionInLine: 1.']}, u'status': 400}

Have anyone experienced a similar problem? The error seems to indicate a problem with the start of the "property name". Is it a problem with the body that I've defined?

I've verified the call I'm trying to make using Swagger. There is nothing there indicating that this is not a correct postData body.

Thank full for any help that I could get  
BR

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 30, 2022, 3:31pm UTC](https://forum.inductiveautomation.com/t/httppost-response-400-error/57821/2 "2022-03-30T15:31:38Z")

</div>

You need to call system.util.jsonEncode on your body before you pass it to `httpPost`.

Or if you’re on Ignition 8.x you should use system.net.httpClient instead.

---

<div class="post-metadata">

**Author:** ![Staffan\_William-Olss](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@Staffan\_William-Olss](https://forum.inductiveautomation.com/u/Staffan_William-Olss)\
**Post date:** [March 30, 2022, 3:37pm UTC](https://forum.inductiveautomation.com/t/httppost-response-400-error/57821/3 "2022-03-30T15:37:51Z")

</div>

That did the trick! Thank you!  
I’m on 8.4 on this gateway, so I will consider migrating the code to httpClient
