0

I'm shooting a POST request to a local server but the response I get back from the server is that the "Token is missing". I get a 200 OK response so it's connects just fine but the response is that the Token is missing. But I have added the Token according to the API instructions.

Can anyone see what I'm doing wrong? It's driving me crazy. The URL, IP Address, Port and Authorization are all correct but when I run a GET request, that works just fine.

POST /url/example HTTP/1.1
Host: 192.168.124.33:7001
Authorization: Basic abcdefghijklmnop=

token: JDI1M2UwOWVhOTA3ZDU2ZDMkdA==
xml: <?xml version="1.0" encoding="UTF-8"?>
....

Unfortunately, I can't say specifically which API this is as I am under an NDA.

EDIT: I should also note that running this process from the API itself (it has a test button), works fine. Looking at the Request Headers and Body in Chrome Dev Tools shows that I am sending the same text as the API.

MoebiusUK
  • 11
  • 6

2 Answers2

0

Can you check if your token have enough permission of doing post /modify the data

  • How do I check? If permission was an issue, surely the error wouldn't be that the "Token is missing", right? – MoebiusUK Oct 05 '15 at 16:12
  • May be it show token miss match that you will get in api document how the api behave ... You can try advance rest client or postman extensions of chrome,if that makes some change in response – Sayak Mukherjee Oct 05 '15 at 16:40
  • I tried my code with Postman got the same "Token is missing" error. – MoebiusUK Oct 05 '15 at 16:52
0

The extra newline between Authorization and token may cause problem. In HTTP request format a double CRLF marks end of header and start of body. I am not sure if this newline is intentional, but if you want this token to be part of your request header, please try once without this newline i.e.

POST /url/example HTTP/1.1
Host: 192.168.124.33:7001
Authorization: Basic abcdefghijklmnop=
token: JDI1M2UwOWVhOTA3ZDU2ZDMkdA==
xml: <?xml version="1.0" encoding="UTF-8"?>
...
tilmik
  • 123
  • 1
  • 2
  • 11
  • As far as I've been told, the Token: and XML: are part of the body. I've never seen that syntax for the body though. Have you? – MoebiusUK Oct 05 '15 at 16:54
  • Please check [this question](http://stackoverflow.com/questions/14551194/how-are-parameters-sent-in-an-http-post-request) – tilmik Oct 06 '15 at 04:39