First, let me start by saying I have got absolutely nothing working with OData4j.
I am building an android app (using Eclipse) that needs to consume some OData from a web service, we have an iPad app already which work fine so I think it's safe to the the web services are ok.
All of the web requests require basic authentication to work, and I am able to make the calls using a browser to confirm that the URL and credentials I am using are valid.
So far I have this code:
ODataConsumer.Builder builder = ODataConsumers.newBuilder(url);
builder.setClientBehaviors(new BasicAuthenticationBehavior(LoginUsername, LoginPassword));
ODataConsumer c = builder.build();
for(OEntity entity : c.getEntities("entry").execute()){
System.out.println(entity.getProperty("name").getValue().toString());
}
Currently, the Eclipse debugger fails on the for
line, presumable during the .execute()
call. The debugger is zero help to me, the only line that looks half-relevant in the LogCat is:
EDIT: After @JohnSpurlock's answer, I got a little further. Same problem overall, but a new error message:
BadRequestException: The request URI is not valid. Since the segment 'Documents' refers to a collection, this must be the last seqment in the request URL. All intermediate segments must refer to a single resource.
There are other messages but mostly to do with threading - it is worth noting that this method is being called from within an AsyncTask, but it seem common to have the threading errors when anything breaks within an AsyncTask
.
A censored and shortened version of my XML result (via a browser) looks like this:
<feed xml:base="http://a.example.com/OData.svc/"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns="http://www.w3.org/2005/Atom">
<entry>
<name>one</name>
</entry>
<entry>
<name>two</name>
</entry>
</feed>