HttpPost Error 400

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

Try this.


params = {‘test1’: 1, ‘10000’: 2, ‘500000’: 3}
res1 =“”, params)
res2 =“”, params)

print res1,
print res2

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 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?

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.

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.

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.

Have you tried using keyword arguments?,contentType=“application/json”,postData=postData,connectTimeout=10000,readTimeout=30000,username=“admin”,password=“Admin1234”)

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