login in the REST API is not working using CURL
I just installed Youtrack 4.1.3 WAR in glassfish 3.1.2.2 that is reversed proxied through an nginx server, and I want to try out the REST API for integrating it with some tools I have.
curl -D- -v -X POST -H "Content-Type: application/x-www-form-urlencoded" –data-urlencode "login=XXXX&password=XXXX" http://xxxx.xxxx.xxx/rest/user/login
I get a 400 Bad Request Response, here's the whole request/response:
About to connect() to xxxx.xxxx.xxx port 80 (#0)
HTTP/1.1 400 Bad Request
< Server: nginx/1.0.15
Server: nginx/1.0.15
< Date: Sun, 27 Jan 2013 19:24:36 GMT
Date: Sun, 27 Jan 2013 19:24:36 GMT
< Content-Type: application/xml;charset=UTF-8
Content-Type: application/xml;charset=UTF-8
< Connection: keep-alive
Connection: keep-alive
< X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)
X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)
< Set-Cookie: JSESSIONID=d77ec861ef1a4494e04479f70e9b; Path=/; HttpOnly
Set-Cookie: JSESSIONID=d77ec861ef1a4494e04479f70e9b; Path=/; HttpOnly
< Cache-Control: no-cache, no-store, no-transform, must-revalidate
Cache-Control: no-cache, no-store, no-transform, must-revalidate
< Content-Length: 81
Content-Length: 81
<
Anyone knows then what am I doing wrong? I'm following all parameters that the REST API documentation dictates but still nothing.
Thanks
curl -D- -v -X POST -H "Content-Type: application/x-www-form-urlencoded" –data-urlencode "login=XXXX&password=XXXX" http://xxxx.xxxx.xxx/rest/user/login
I get a 400 Bad Request Response, here's the whole request/response:
About to connect() to xxxx.xxxx.xxx port 80 (#0)
- Trying XXX.XXX.XXX.XXX...
- connected
- Connected to xxxx.xxxx.xxx (XXX.XXX.XXX.XXX) port 80 (#0)
POST /rest/user/login HTTP/1.1
User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
Host: xxxx.xxxx.xxx
Accept: /
Content-Type: application/x-www-form-urlencoded
Content-Length: 41
- upload completely sent off: 41 out of 41 bytes
HTTP/1.1 400 Bad Request
< Server: nginx/1.0.15
Server: nginx/1.0.15
< Date: Sun, 27 Jan 2013 19:24:36 GMT
Date: Sun, 27 Jan 2013 19:24:36 GMT
< Content-Type: application/xml;charset=UTF-8
Content-Type: application/xml;charset=UTF-8
< Connection: keep-alive
Connection: keep-alive
< X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)
X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)
< Set-Cookie: JSESSIONID=d77ec861ef1a4494e04479f70e9b; Path=/; HttpOnly
Set-Cookie: JSESSIONID=d77ec861ef1a4494e04479f70e9b; Path=/; HttpOnly
< Cache-Control: no-cache, no-store, no-transform, must-revalidate
Cache-Control: no-cache, no-store, no-transform, must-revalidate
< Content-Length: 81
Content-Length: 81
<
- Connection #0 to host xxxx.xxxx.xxx left intact
Anyone knows then what am I doing wrong? I'm following all parameters that the REST API documentation dictates but still nothing.
Thanks
1 comment
Sort by
Date
Votes
Found the problem... I was URL encoding the data, and I changed it to raw data and the problem is gone, thanks!
Please sign in to leave a comment.