I cant login using API

Manager-serv8 years ago

Hello, please help me, i'm working in a app for traccar and i cant login using API

I'm using this site for test API: https://www.hurl.it/

This is the URL

http://demo.traccar.org/api/session

This is my POST request:

HEADERS

Accept: */*
Accept-Encoding: gzip, deflate
Content-Length: 63
Content-Type: application/json
User-Agent: runscope/0.1

BODY

{ email: "myemail", password:"mypassword" }

This is the response

HEADERS

Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: origin, content-type, accept, authorization
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin: *
Content-Length: 61
Date: Sat, 24 Feb 2018 23:53:20 GMT
Server: Jetty(9.2.22.v20170606)

BODY

HTTP 415 Unsupported Media Type - NotSupportedException (...)
Anton Tananaev8 years ago

Have you read API documentation? It accepts application/x-www-form-urlencoded media type.

Anton Tananaev8 years ago

Also, even if it accepted JSON, your JSON is invalid. Keys in JSON format always need to be in double-quotes.

Manager-serv8 years ago

Hello Anton. Thanks for your fast reply. I change the media type but not work

Request

HEADERS

Accept: */*
Accept-Encoding: gzip, deflate
Content-Length: 63
Content-Type: application/x-www-form-urlencoded
User-Agent: runscope/0.1

BODY

{"email": "myemail", "password":"mypassword" }

Responde

Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: origin, content-type, accept, authorization
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin: *
Content-Length: 91
Content-Type: application/json
Date: Sun, 25 Feb 2018 01:48:13 GMT
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Server: Jetty(9.2.22.v20170606)
Set-Cookie: JSESSIONID=fi1nu3e5g2cdnkxgyesu2z60;Path=/api

BODY

NullPointerException (DataManager:306 < PermissionsManager:412 < SessionResource:103 < ...)
Anton Tananaev8 years ago

I would recommend you to read about different media types and what they mean. There is plenty of documentation online.

Manager-serv8 years ago

Please help me, i wanna to know where is the mistake and right way yo make this call... Please

Manager-serv8 years ago

please do not be offended but I can pay you for this. tell me what the price could be

Anton Tananaev8 years ago

Send an email to support address if you are interested in paid support.