POST error with JSON data
Posted: Mon May 09, 2016 2:36 pm
I am trying to POST data to Backendless (which is a backend service in case you couldn't guess)
I am out of ideas as to how to troubleshoot this, can anyone notice something wrong or recommend anything else I can check?
so theURL is: https://api.backendless.com/v1/users/login
and theData is: {"login" : "greg@mad.pink", "password" : "REDACTED"}
and when I use this command: post theData to URL theURL
I get the following:
1. it and urlResponse both say "Expecting JSON data"
2. the result says "error 400 Bad Request"
3. and from libURLLastRHHeaders() I get:
HTTP/1.1 400 Bad Request
Access-Control-Allow-Headers: Origin, application-id, application-type, Content-Type, secret-key, request, user-token
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, PATCH
Access-Control-Allow-Origin: *
Content-Type: text/plain; charset=utf-8
Date: Mon, 09 May 2016 13:20:48 GMT
Server: nginx/1.8.1
Content-Length: 19
Connection: keep-alive
The following curl call works the way it should:
curl -H application-id:XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX \
-H secret-key:XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX \
-H Content-Type:application/json \
-H application-type:REST \
-X POST \
-v 'https://api.backendless.com/v1/users/login' \
-d '{"login" : "greg@mad.pink", "password" : "REDACTED"}'
I am out of ideas as to how to troubleshoot this, can anyone notice something wrong or recommend anything else I can check?
so theURL is: https://api.backendless.com/v1/users/login
and theData is: {"login" : "greg@mad.pink", "password" : "REDACTED"}
and when I use this command: post theData to URL theURL
I get the following:
1. it and urlResponse both say "Expecting JSON data"
2. the result says "error 400 Bad Request"
3. and from libURLLastRHHeaders() I get:
HTTP/1.1 400 Bad Request
Access-Control-Allow-Headers: Origin, application-id, application-type, Content-Type, secret-key, request, user-token
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, PATCH
Access-Control-Allow-Origin: *
Content-Type: text/plain; charset=utf-8
Date: Mon, 09 May 2016 13:20:48 GMT
Server: nginx/1.8.1
Content-Length: 19
Connection: keep-alive
The following curl call works the way it should:
curl -H application-id:XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX \
-H secret-key:XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX \
-H Content-Type:application/json \
-H application-type:REST \
-X POST \
-v 'https://api.backendless.com/v1/users/login' \
-d '{"login" : "greg@mad.pink", "password" : "REDACTED"}'