0

I am supposed to send information to server using curl but my embedded device doesn't support libcurl library yet. As I googled it out, it looks like I can use POST and get things done but am getting error 400 from server when I do the same. All I had to do with Curl was that to add HTTP header and then post data and it goes like

URL shared:

https://api.sampledomain.com/v1/action

Header:

Authorization: Bearer aabbccddee

Data:

{"action":"112233445566","device_id":"1234567890"} 

Below is the POST command I compiled and the string goes like below.

POST /v1/action HTTP/1.1
Host: api.sampledomain.com
Authorization: Bearer aabbccddee
{"action":"112233445566","device_id":"1234567890"}

Response for the above POST command was: 400

Please help me out guys. Thanks.

Vasanth
  • 128
  • 1
  • 18
  • I used the below link to confirm that it's possible to use POST instead of relying on curl. https://stackoverflow.com/questions/16877968/call-a-server-side-method-on-a-resource-in-a-restful-way – Vasanth Mar 04 '18 at 01:01

1 Answers1

0

Looks like a syntax error. I had to give two spaces below the data section after the curly braces. It worked like a charm.

POST /v1/action HTTP/1.1
Content-Type: application/json
Content-Length: 105
Host: api-sampledomain.com
Authorization: Bearer aabbccddee

{"action":"112233445566","device_id":"12345678"}
Vasanth
  • 128
  • 1
  • 18