Windows 11
I'm attempting what should be a pedestrian API request, but I'm getting an error in Postman (which might be a Postman bug).
The API call is possible because it runs on an Android app that logs the JSON request and response (but no other data about the API, sadly enough).
The call is to a small device. The small device has Wi-Fi, so I can connect from my PC to the small device. The API is simple:
- http protocol
- call to a specific Ip address and a specific port
- JSON, with two key:value pairs
And I get this error:
Notice the "Parse Error: Expected HTTP/" there at the top. Here's a Stack Overflow thread that comes to the conclusion that this is a bug in Postman, so... try curl! People do, and it works... for them.
When I try, I get a whole new set of issues. It connects, but gives me an error. Here's my command:
curl.exe -v -d "{"token":0, "msg_id":257}" -H "Content-Type: application/json" http://192.168.42.1:7878
And here's the "response" I get.
* Trying 192.168.42.1:7878...
* Connected to 192.168.42.1 (192.168.42.1) port 7878 (#0)
> POST / HTTP/1.1
> Host: 192.168.42.1:7878
> User-Agent: curl/8.0.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 21
>
* Received HTTP/0.9 when not allowed
* Closing connection 0
curl: (1) Received HTTP/0.9 when not allowed
"Received HTTP/0.9 when not allowed". OK. Some Googling leads me to this blog, where the blogger confidently says to try the flag --http0.9
, so I add it.
curl.exe -v -d "{"token":0, "msg_id":257}" -H "Content-Type: application/json" --http0.9 http://192.168.42.1:7878
* Trying 10.0.0.254:7878...
* Connected to 10.0.0.254 (10.0.0.254) port 7878 (#0)
> POST / HTTP/1.1
> Host: 10.0.0.254:7878
> User-Agent: curl/8.0.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 21
>
{"rval":-4,"msg_id":0} BLINKING CURSOR, IS HANGING
Not only will the API not finish, that's not the response I should get. I should get this:
{"rval":0, "msg_id":257, "param": <TokenNumber>}
I'm way outside of my knowledge zone here. Does anyone have any ideas on what's happening?
Everything I've tried is described above.