read atom feed

Jun 15, 2011 at 8:59 AM

Hey everybody,

Currently I am trying to read an atom feed, but I always get the error "invalid label". I think that there is a problem with the callback handler as it it set to Jsonp. Without  "OData.defaultHttpClient.enableJsonpCallback = true;" I get the 401 (not authorized Error).

Please help, I was not able to find an example for reading an atom feed.

Best regards and thanks in advance,


Jun 15, 2011 at 6:05 PM

datajs should be able to deal with an OData payload regardless of whether it's JSON or ATOM-based.

Do you need some form of authentication on the server? Can you share the HTTP traces for the cases with jsonp on true / false?

Jun 15, 2011 at 9:27 PM

Caranthor, I've just posted a video on how to get simple HTTP traces. Just capture these while your page is running, that should provide more information on what's going on.

Jun 17, 2011 at 9:08 AM
Edited Jun 17, 2011 at 9:25 AM


I use Firebug for tracing. Can't save in XML files. Anyways, When Json callback is true the parameters that are sent are:

$callback handleJSONP_0
$format json
sap-client  100
The Server returns the Following answer. 

<?xml version="1.0" encoding="utf-8"?><atom:feed xml:base="

datajs expects json, but receives atom => can't deal with it.

When jsonp callback is false: Parameters: only sap-client 100 (set by me, not by the framework)
and no answer, instead Status 401 (unauthorized).

*edit* yes, i need authentication. first time a sign in pop up is used for authentication

Thank you
Jun 20, 2011 at 7:15 PM

Caranthor, can you tell me what software is service OData from the server?

From your description, it looks like asking for JSON through the $format query parameter doesn't make the server return JSON - it ignores it and returns ATOM XML instead.

When setting JSONP to false, datajs still makes an attempt to use XMLHttpRequest. In this case, Firefox will try to do a cross-domain request if the server allows it, but it won't flow authentication information by default (which is probably why you're getting the 401 response from the server). Using withCredentials as per should help in this case.

Note however that XHR in cross-domain scenarios are not widely / consistently implemented in browsers, so it's a tricky proposition.