Sending POST requests in Python

Hi, I am new to Chirpstack. I have visited several places for solution, including some posts on this forum.

I am sending a post request to my localhost:8080, via python script. But it showed an error “device must not be nil”.
image

I inserted the same parameters in the api web interface and successfully added a device. I logged into the webUI and the newly added device was there.

I checked the error, device can not be nil on github repo, and it only said that the variables have some problem, but not specifying which. But I think the parameters are ok since I have successfully sent many get requests.

I found online that that there might be some problem with python sending a json request with true/false, since the bool values are True/False in python rather than true/false. On sending Rest API POST request through python, some internet articles suggested that I should jam the parts involved with Boolean value into a single string. I tried this method but the same error showed up.

I used GET in some other functions and they were ok so I think it is the problem of that dictionary (or json). I noticed that there aren’t much information on using the python to communicate with chirpstack.

I am thinking about 2 ways to get out of this. One is to learn golang, which is new to me and can possibly solve the issue, and the other is using the python SDK. I can not be the first one to come across the problem, I guess. Thanks in advance.

1 Like

the way booleans are depicted in Python (i.e. “True” vs. “true”) is irrelevant since all payloads are sent as JSON encoded. If you run Wireshark to see what is going out to the internets, you will see this holds true.

If you have a “working” payload, then you should try to debug which fields it has specified and try to compare that to your python example above.