Http response code _ 422

Error:
Traceback (most recent call last):
File "", line 64, in
File "", line 61, in update_cloud_mode
IOError: Server returned HTTP response code: 422 for URL: http://10.207.21.46/cloud/mode

code:
<data_final = json.dumps(Data)
print(type(data_final))
print system.net.httpPut(url, data_final, headerValues = headers)>
data_final is of type

Can someone tell me how to fix this please?

You should get comfortable with server codes - HTTP response status codes - HTTP | MDN

For 422 -

422 Unprocessable Content
The request was well-formed but was unable to be followed due to semantic errors.

So seems like for the most part your request is fine but perhaps the data you sent was malformed / not what the server is expecting

Thank you for the response. I do understand the server codes but I have tried to feed it all kinds of data, dictionary and string (which it can possibly accept).

Since it is giving the same error. So i thought of asking it here

Normally API's should have documentation on what you should be sending them. Do you have a link to that?

Also,

  • You are using httpPut(). That is a legacy function that isn't expected to work with the security on most modern web servers. Learn to use system.net.httpClient() for everything.

  • Consider using wireshark to see what you are really sending and receiving.

@pturmel Thank you so much sir!

@pturmel Can you please tell me the syntax for httpClient() or a place where I can find it for the PUT commands

User manual?

https://docs.inductiveautomation.com/display/DOC81/system.net.httpClient

Lots of examples here on the forum, too.