Correct format for HTTP/1.1 API replies

I am creating an embedded web API interface in a gadget that I am building.
I’m able to set the device up as a AP, create a Socket and listen on Port 80.
It receives an API GET request from Postman.

This is what I receive…

GET /HelloWorl HTTP/1.1                        
User-Agent: PostmanRuntime/7.29.0                                               
Accept: */*                                                                     
Postman-Token: 72cac2d1-8da1-4274-80b1-d53275016f67                             
Host: 192.168.230.3                                                             
Accept-Encoding: gzip, deflate, br                                              
Connection: keep-alive            

This is what I am sending back in response to the GET…

HTTP/1.1 200 
Connection: OK keep-alive 
Postman-Token: cd3b8bf5-7d75-433a-88b2-4908b418a267
Content-Type: application/json
{"id": 10,"name": "shirt","color": "red","price": "$23"}

This what I observe on Wireshark…

image

This is the error message I get in Postman…

Parse Error: There seems to be an invalid character in response header key or value

Can someone identify what I am doing wrong here?

Hi @andyquant2020

Could you screenshot your GET request + headers and your Response + headers in Postman?
Might help to visualise what you are doing.

GET request

Response

Does the response Postman-Token need to match the Postman-Token supplied in the GET request?

I have solved the issue I was having myself.
Including the content length appears to have fix my problem

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 44
{“type”:“pressure”,“value”:300,“unit”:“hPa”}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.