Authentication failed

20 views
Skip to first unread message

Juanmi

unread,
Mar 26, 2011, 5:41:12 AM3/26/11
to SlimTimer Developer Forum
Hello!

I'm just starting to try SlimTimer API from Java and I get
Authentication failed XML response. This is my code:

DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost post = new HttpPost("http://slimtimer.com/users/token");
StringEntity xml = new StringEntity("<?xml version=\"1.0\" encoding=
\"UTF-8\"?><request><user><email>jms...@XXX.com</email><password>XXX</
password></user><api-key>" +
API_KEY + "</api-key></request>");

xml.setContentType("application/xml");
post.setEntity(xml);
HttpResponse response = httpClient.execute(post);
HttpEntity entity = response.getEntity();

if (entity != null) {
System.out.println(entity.getContentType().getValue());
System.out.println(EntityUtils.toString(entity));
}

This is the output:

application/xml; charset=utf-8
<?xml version="1.0" encoding="UTF-8"?>
<errors>
<error>Authentication failed</error>
</errors>

What I'm doing wrong?

Richard White

unread,
Mar 29, 2011, 12:17:02 AM3/29/11
to slimti...@googlegroups.com, Juanmi
Set your HTTP_ACCEPTS header to "xml" it's not enough to just set the content-type.


--
You received this message because you are subscribed to the Google Groups "SlimTimer Developer Forum" group.
To post to this group, send email to slimti...@googlegroups.com.
To unsubscribe from this group, send email to slimtimerapi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/slimtimerapi?hl=en.


Juanmi

unread,
Mar 29, 2011, 2:53:48 AM3/29/11
to SlimTimer Developer Forum
Thanks. I was confused by that error message.
Reply all
Reply to author
Forward
0 new messages