You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Jonathan Peterson <jo...@gmail.com> on 2014/10/27 21:33:04 UTC

Expected OData Entity, found EntitySet

I'm trying to use Olingo to connect to an Odata v4 service from Android.
I'm having a bit of trouble getting the filter to work

I've tested it with the Northwind sample and the URI that gets produce
works in a browser:

http://services.odata.org/Experimental/Northwind/Northwind.svc/Customers?%24filter=%28CustomerID+eq+%27ALFKI%27%29

I always get the following error:
=============================
java.lang.IllegalArgumentException:
org.apache.olingo.commons.api.serialization.ODataDeserializerException:
com.fasterxml.jackson.core.JsonParseException: Expected OData Entity, found
EntitySet
=============================

I'm using this code:

=============================
String serviceUrl = "
http://services.odata.org/Experimental/Northwind/Northwind.svc";
String entity = "Customers";
String filter = "CustomerID";
String id = "ALFKI";

try {
final ODataEntityRequest<ODataEntity> jsonReq =
client.getRetrieveRequestFactory().
getEntityRequest(client.newURIBuilder(serviceUrl).
appendEntitySetSegment(entity)
.filter(client.getFilterFactory().eq(filter,id)).build());

Log.v(TAG, "URI: " + jsonReq.getURI());

final ODataEntity spammer = jsonReq.execute().getBody(); //blows up here
=============================

how do I get the filter to work??

Thanks

Re: Expected OData Entity, found EntitySet

Posted by mibo <mi...@apache.org>.
Hello,

> Am 28.10.2014 um 16:22 schrieb Alex Maiereanu <al...@3sstudio.com>:
> 
> I think that us, as users, need to chip in with the documentation, since this is an open project

every form of help and contribution is welcome.
Especially for documentation and support on the mailing list.
In addition we want to grow a friendly and helpful community for Olingo  ;o)

Thanks to all and kind regards,
Michael


> 
>  Salutari din Brasov /  Greetings from Brasov
> 
> Alex-Paul Maiereanu
> 
> +40 761 684 212
> www.3sstudio.com
> 
> Facebook Twitter Google+
> 
> On Tue, Oct 28, 2014 at 5:19 PM, Jonathan Peterson <jo...@gmail.com> wrote:
> Ah!
> 
> Thanks Fabio. That's what I was missing. I tried changing the ODataEntity to ODataEntitySet but I didn't realize that I needed to change it to ODataEntitySetRequest.
> 
> Also, it looks like I need to change that to .getEntitySetRequest as well.
> 
> My code now looks like this and works:
> 
>  final ODataEntitySetRequest<ODataEntitySet> jsonReq = client.getRetrieveRequestFactory().
>     getEntitySetRequest(client.newURIBuilder(serviceUrl).
>     appendEntitySetSegment(entity).
>     filter(client.getFilterFactory().eq(filter,id)).build());
> 	
> final List<ODataEntity> results = jsonReq.execute().getBody().getEntities();
> 
> You guys need some documentation on the v4 stuff :)
> 
> 


Re: Expected OData Entity, found EntitySet

Posted by Alex Maiereanu <al...@3sstudio.com>.
I think that us, as users, need to chip in with the documentation, since
this is an open project

 Salutari din Brasov /  Greetings from Brasov

Alex-Paul Maiereanu

+40 761 684 212

www.3sstudio.com

Facebook <https://www.facebook.com/smartsocialsoftware> Twitter
<https://twitter.com/SmartSocialSoft> Google+
<https://plus.google.com/101299629750815349588/posts>

On Tue, Oct 28, 2014 at 5:19 PM, Jonathan Peterson <jo...@gmail.com>
wrote:

> Ah!
>
> Thanks Fabio. That's what I was missing. I tried changing the ODataEntity
> to ODataEntitySet but I didn't realize that I needed to change it to
> ODataEntitySetRequest.
>
> Also, it looks like I need to change that to .getEntitySetRequest as well.
>
> My code now looks like this and works:
>
>  final ODataEntitySetRequest<ODataEntitySet> jsonReq =
> client.getRetrieveRequestFactory().
>     getEntitySetRequest(client.newURIBuilder(serviceUrl).
>     appendEntitySetSegment(entity).
>     filter(client.getFilterFactory().eq(filter,id)).build());
> final List<ODataEntity> results =
> jsonReq.execute().getBody().getEntities();
>
> You guys need some documentation on the v4 stuff :)
>
>
>
>
> On Tue Oct 28 2014 at 10:13:23 AM Fabio Martelli <fa...@gmail.com>
> wrote:
>
>>  Il 28/10/2014 15:00, Jonathan Peterson ha scritto:
>>
>> I don't think I really need proxy classes for this project. In this case,
>> I'm going to be making the same request with a different ID to get one
>> property from the feed.
>>
>>  I looked at the Android tutorial already, however there's no simple
>> "get where this is that" sample (which is really weird)
>>
>>  I try the .filter(" CustomerID eq 'ALFKI' ") I still get the same error
>> as before. "Expected OData Entity, found EntitySet"
>>
>> Hi Jonathan, .filter() method return an entity set.
>> You should do something like as the following
>>
>>
>> String serviceUrl =
>> "http://services.odata.org/Experimental/Northwind/Northwind.svc"
>> <http://services.odata.org/Experimental/Northwind/Northwind.svc>;
>> String entity = "Customers";
>> String filter = "CustomerID";
>> String id = "ALFKI";
>>
>> try {
>>     final ODataEntitySetRequest<ODataEntitySet> jsonReq =
>> client.getRetrieveRequestFactory().
>>     getEntityRequest(client.newURIBuilder(serviceUrl).
>>     appendEntitySetSegment(entity).
>>     filter(client.getFilterFactory().eq(filter,id)).build());
>>
>>     final ODataEntitySet feed = req.execute().getBody();
>>     ..... loop on entity set .....
>>
>> }catch(....){
>>     .....
>> }
>>
>> Best regards,
>> F.
>>
>>
>> On Tue Oct 28 2014 at 6:06:41 AM Alex Maiereanu <
>> alex.maiereanu@3sstudio.com> wrote:
>>
>>> 1, you should actually try to use the proxy classes. It will save you a
>>> lot of pain.
>>> 2, I didnt use the RequestFactory that much, so i'm guessing right now.
>>> We also had some issue with the filter factory, and ended up just to use
>>> some strings. In your case
>>>
>>>  .filter(" CustomerID eq 'ALFKI' ")
>>>
>>>  Also have a look here
>>>
>>>
>>> https://github.com/Tirasa/olingoClientOnAndroidSample/blob/master/src/main/java/net/tirasa/olingo4android/Main.java
>>>
>>>  If you need help with generating the proxy classes, I can help you
>>> with that
>>>
>>>
>>>   Salutari din Brasov /  Greetings from Brasov
>>>
>>> Alex-Paul Maiereanu
>>>
>>> +40 761 684 212
>>>
>>> www.3sstudio.com
>>>
>>> Facebook <https://www.facebook.com/smartsocialsoftware> Twitter
>>> <https://twitter.com/SmartSocialSoft> Google+
>>> <https://plus.google.com/101299629750815349588/posts>
>>>
>>> On Tue, Oct 28, 2014 at 12:20 AM, Jonathan Peterson <jo...@gmail.com>
>>> wrote:
>>>
>>>> 1) nope I'm not using proxy classes.
>>>>
>>>>  2)  I've added
>>>>
>>>>  FilterFactory filterFactory = client.getFilterFactory();
>>>>
>>>>   I've changed my filter to
>>>>
>>>>
>>>> .filter(filterFactory.eq(filterFactory.getArgFactory().property(filter),filterFactory.getArgFactory().property(id))).build());
>>>>
>>>>  and I get:
>>>>
>>>>   Could not find a property named 'ALFKI' on type
>>>> 'NorthwindModel.Customer'
>>>>
>>>>  if I change "id" to
>>>>
>>>>  id = "%27ALFKI%27";
>>>>
>>>>  I'm back to the error message I was at before.
>>>>
>>>>  I'm only trying to retrieve one record here.
>>>>
>>>>  On Mon Oct 27 2014 at 5:14:47 PM Alex Maiereanu <
>>>> alex.maiereanu@3sstudio.com> wrote:
>>>>
>>>>> Hey Jonathan,
>>>>>
>>>>> 1.Are you using the proxy class? Those generated classes will save a
>>>>> lot of time.
>>>>>
>>>>> 2 as for the uri builder,  you can have a look in the framework unit
>>>>> test to see how stuff works.  Here is a test for filtering.
>>>>>
>>>>>
>>>>> https://github.com/apache/olingo-odata4/blob/master/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java
>>>>> On Oct 27, 2014 10:34 PM, "Jonathan Peterson" <jo...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> I'm trying to use Olingo to connect to an Odata v4 service from
>>>>>> Android. I'm having a bit of trouble getting the filter to work
>>>>>>
>>>>>>  I've tested it with the Northwind sample and the URI that gets
>>>>>> produce works in a browser:
>>>>>>
>>>>>>
>>>>>> http://services.odata.org/Experimental/Northwind/Northwind.svc/Customers?%24filter=%28CustomerID+eq+%27ALFKI%27%29
>>>>>>
>>>>>>  I always get the following error:
>>>>>> =============================
>>>>>> java.lang.IllegalArgumentException:
>>>>>> org.apache.olingo.commons.api.serialization.ODataDeserializerException:
>>>>>> com.fasterxml.jackson.core.JsonParseException: Expected OData Entity, found
>>>>>> EntitySet
>>>>>> =============================
>>>>>>
>>>>>>  I'm using this code:
>>>>>>
>>>>>>  =============================
>>>>>> String serviceUrl = "
>>>>>> http://services.odata.org/Experimental/Northwind/Northwind.svc";
>>>>>> String entity = "Customers";
>>>>>> String filter = "CustomerID";
>>>>>> String id = "ALFKI";
>>>>>>
>>>>>>  try {
>>>>>> final ODataEntityRequest<ODataEntity> jsonReq =
>>>>>> client.getRetrieveRequestFactory().
>>>>>>  getEntityRequest(client.newURIBuilder(serviceUrl).
>>>>>>  appendEntitySetSegment(entity)
>>>>>>  .filter(client.getFilterFactory().eq(filter,id)).build());
>>>>>>
>>>>>>  Log.v(TAG, "URI: " + jsonReq.getURI());
>>>>>>
>>>>>>  final ODataEntity spammer = jsonReq.execute().getBody(); //blows up
>>>>>> here
>>>>>> =============================
>>>>>>
>>>>>>  how do I get the filter to work??
>>>>>>
>>>>>>  Thanks
>>>>>>
>>>>>
>>>
>>
>> --
>> Fabio Martelli
>>
>> Tirasa - Open Source Excellencehttp://www.tirasa.net/
>>
>> Apache Syncope PMChttp://people.apache.org/~fmartelli/
>>
>>

Re: Expected OData Entity, found EntitySet

Posted by Jonathan Peterson <jo...@gmail.com>.
Ah!

Thanks Fabio. That's what I was missing. I tried changing the ODataEntity
to ODataEntitySet but I didn't realize that I needed to change it to
ODataEntitySetRequest.

Also, it looks like I need to change that to .getEntitySetRequest as well.

My code now looks like this and works:

 final ODataEntitySetRequest<ODataEntitySet> jsonReq =
client.getRetrieveRequestFactory().
    getEntitySetRequest(client.newURIBuilder(serviceUrl).
    appendEntitySetSegment(entity).
    filter(client.getFilterFactory().eq(filter,id)).build());
final List<ODataEntity> results = jsonReq.execute().getBody().getEntities();

You guys need some documentation on the v4 stuff :)




On Tue Oct 28 2014 at 10:13:23 AM Fabio Martelli <fa...@gmail.com>
wrote:

>  Il 28/10/2014 15:00, Jonathan Peterson ha scritto:
>
> I don't think I really need proxy classes for this project. In this case,
> I'm going to be making the same request with a different ID to get one
> property from the feed.
>
>  I looked at the Android tutorial already, however there's no simple "get
> where this is that" sample (which is really weird)
>
>  I try the .filter(" CustomerID eq 'ALFKI' ") I still get the same error
> as before. "Expected OData Entity, found EntitySet"
>
> Hi Jonathan, .filter() method return an entity set.
> You should do something like as the following
>
>
> String serviceUrl =
> "http://services.odata.org/Experimental/Northwind/Northwind.svc"
> <http://services.odata.org/Experimental/Northwind/Northwind.svc>;
> String entity = "Customers";
> String filter = "CustomerID";
> String id = "ALFKI";
>
> try {
>     final ODataEntitySetRequest<ODataEntitySet> jsonReq =
> client.getRetrieveRequestFactory().
>     getEntityRequest(client.newURIBuilder(serviceUrl).
>     appendEntitySetSegment(entity).
>     filter(client.getFilterFactory().eq(filter,id)).build());
>
>     final ODataEntitySet feed = req.execute().getBody();
>     ..... loop on entity set .....
>
> }catch(....){
>     .....
> }
>
> Best regards,
> F.
>
>
> On Tue Oct 28 2014 at 6:06:41 AM Alex Maiereanu <
> alex.maiereanu@3sstudio.com> wrote:
>
>> 1, you should actually try to use the proxy classes. It will save you a
>> lot of pain.
>> 2, I didnt use the RequestFactory that much, so i'm guessing right now.
>> We also had some issue with the filter factory, and ended up just to use
>> some strings. In your case
>>
>>  .filter(" CustomerID eq 'ALFKI' ")
>>
>>  Also have a look here
>>
>>
>> https://github.com/Tirasa/olingoClientOnAndroidSample/blob/master/src/main/java/net/tirasa/olingo4android/Main.java
>>
>>  If you need help with generating the proxy classes, I can help you with
>> that
>>
>>
>>   Salutari din Brasov /  Greetings from Brasov
>>
>> Alex-Paul Maiereanu
>>
>> +40 761 684 212
>>
>> www.3sstudio.com
>>
>> Facebook <https://www.facebook.com/smartsocialsoftware> Twitter
>> <https://twitter.com/SmartSocialSoft> Google+
>> <https://plus.google.com/101299629750815349588/posts>
>>
>> On Tue, Oct 28, 2014 at 12:20 AM, Jonathan Peterson <jo...@gmail.com>
>> wrote:
>>
>>> 1) nope I'm not using proxy classes.
>>>
>>>  2)  I've added
>>>
>>>  FilterFactory filterFactory = client.getFilterFactory();
>>>
>>>   I've changed my filter to
>>>
>>>
>>> .filter(filterFactory.eq(filterFactory.getArgFactory().property(filter),filterFactory.getArgFactory().property(id))).build());
>>>
>>>  and I get:
>>>
>>>   Could not find a property named 'ALFKI' on type
>>> 'NorthwindModel.Customer'
>>>
>>>  if I change "id" to
>>>
>>>  id = "%27ALFKI%27";
>>>
>>>  I'm back to the error message I was at before.
>>>
>>>  I'm only trying to retrieve one record here.
>>>
>>>  On Mon Oct 27 2014 at 5:14:47 PM Alex Maiereanu <
>>> alex.maiereanu@3sstudio.com> wrote:
>>>
>>>> Hey Jonathan,
>>>>
>>>> 1.Are you using the proxy class? Those generated classes will save a
>>>> lot of time.
>>>>
>>>> 2 as for the uri builder,  you can have a look in the framework unit
>>>> test to see how stuff works.  Here is a test for filtering.
>>>>
>>>>
>>>> https://github.com/apache/olingo-odata4/blob/master/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java
>>>> On Oct 27, 2014 10:34 PM, "Jonathan Peterson" <jo...@gmail.com>
>>>> wrote:
>>>>
>>>>> I'm trying to use Olingo to connect to an Odata v4 service from
>>>>> Android. I'm having a bit of trouble getting the filter to work
>>>>>
>>>>>  I've tested it with the Northwind sample and the URI that gets
>>>>> produce works in a browser:
>>>>>
>>>>>
>>>>> http://services.odata.org/Experimental/Northwind/Northwind.svc/Customers?%24filter=%28CustomerID+eq+%27ALFKI%27%29
>>>>>
>>>>>  I always get the following error:
>>>>> =============================
>>>>> java.lang.IllegalArgumentException:
>>>>> org.apache.olingo.commons.api.serialization.ODataDeserializerException:
>>>>> com.fasterxml.jackson.core.JsonParseException: Expected OData Entity, found
>>>>> EntitySet
>>>>> =============================
>>>>>
>>>>>  I'm using this code:
>>>>>
>>>>>  =============================
>>>>> String serviceUrl = "
>>>>> http://services.odata.org/Experimental/Northwind/Northwind.svc";
>>>>> String entity = "Customers";
>>>>> String filter = "CustomerID";
>>>>> String id = "ALFKI";
>>>>>
>>>>>  try {
>>>>> final ODataEntityRequest<ODataEntity> jsonReq =
>>>>> client.getRetrieveRequestFactory().
>>>>>  getEntityRequest(client.newURIBuilder(serviceUrl).
>>>>>  appendEntitySetSegment(entity)
>>>>>  .filter(client.getFilterFactory().eq(filter,id)).build());
>>>>>
>>>>>  Log.v(TAG, "URI: " + jsonReq.getURI());
>>>>>
>>>>>  final ODataEntity spammer = jsonReq.execute().getBody(); //blows up
>>>>> here
>>>>> =============================
>>>>>
>>>>>  how do I get the filter to work??
>>>>>
>>>>>  Thanks
>>>>>
>>>>
>>
>
> --
> Fabio Martelli
>
> Tirasa - Open Source Excellencehttp://www.tirasa.net/
>
> Apache Syncope PMChttp://people.apache.org/~fmartelli/
>
>

Re: Expected OData Entity, found EntitySet

Posted by Fabio Martelli <fa...@gmail.com>.
Il 28/10/2014 15:00, Jonathan Peterson ha scritto:
> I don't think I really need proxy classes for this project. In this 
> case, I'm going to be making the same request with a different ID to 
> get one property from the feed.
>
> I looked at the Android tutorial already, however there's no simple 
> "get where this is that" sample (which is really weird)
>
> I try the .filter(" CustomerID eq 'ALFKI' ") I still get the same 
> error as before. "Expected OData Entity, found EntitySet"
Hi Jonathan, .filter() method return an entity set.
You should do something like as the following

String serviceUrl = 
"http://services.odata.org/Experimental/Northwind/Northwind.svc";
String entity = "Customers";
String filter = "CustomerID";
String id = "ALFKI";

try {
     final ODataEntitySetRequest<ODataEntitySet> jsonReq = 
client.getRetrieveRequestFactory().
     getEntityRequest(client.newURIBuilder(serviceUrl).
     appendEntitySetSegment(entity).
     filter(client.getFilterFactory().eq(filter,id)).build());

     final ODataEntitySet feed = req.execute().getBody();
     ..... loop on entity set .....

}catch(....){
     .....
}

Best regards,
F.
>
> On Tue Oct 28 2014 at 6:06:41 AM Alex Maiereanu 
> <alex.maiereanu@3sstudio.com <ma...@3sstudio.com>> wrote:
>
>     1, you should actually try to use the proxy classes. It will save
>     you a lot of pain.
>     2, I didnt use the RequestFactory that much, so i'm guessing right
>     now. We also had some issue with the filter factory, and ended up
>     just to use some strings. In your case
>
>     .filter(" CustomerID eq 'ALFKI' ")
>
>     Also have a look here
>
>     https://github.com/Tirasa/olingoClientOnAndroidSample/blob/master/src/main/java/net/tirasa/olingo4android/Main.java
>
>     If you need help with generating the proxy classes, I can help you
>     with that
>
>
>     Salutari din Brasov /  Greetings from Brasov
>
>     Alex-Paul Maiereanu
>
>     +40 761 684 212
>
>     www.3sstudio.com <http://www.3sstudio.com/>
>
>     Facebook <https://www.facebook.com/smartsocialsoftware> Twitter
>     <https://twitter.com/SmartSocialSoft> Google+
>     <https://plus.google.com/101299629750815349588/posts>
>
>
>     On Tue, Oct 28, 2014 at 12:20 AM, Jonathan Peterson
>     <jonpet2@gmail.com <ma...@gmail.com>> wrote:
>
>         1) nope I'm not using proxy classes.
>
>         2)  I've added
>
>         FilterFactory filterFactory = client.getFilterFactory();
>
>          I've changed my filter to
>
>         .filter(filterFactory.eq(filterFactory.getArgFactory().property(filter),filterFactory.getArgFactory().property(id))).build());
>
>         and I get:
>
>          Could not find a property named 'ALFKI' on type
>         'NorthwindModel.Customer'
>
>         if I change "id" to
>
>         id = "%27ALFKI%27";
>
>         I'm back to the error message I was at before.
>
>         I'm only trying to retrieve one record here.
>
>         On Mon Oct 27 2014 at 5:14:47 PM Alex Maiereanu
>         <alex.maiereanu@3sstudio.com
>         <ma...@3sstudio.com>> wrote:
>
>             Hey Jonathan,
>
>             1.Are you using the proxy class? Those generated classes
>             will save a lot of time.
>
>             2 as for the uri builder,  you can have a look in the
>             framework unit test to see how stuff works.  Here is a
>             test for filtering.
>
>             https://github.com/apache/olingo-odata4/blob/master/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java
>
>             On Oct 27, 2014 10:34 PM, "Jonathan Peterson"
>             <jonpet2@gmail.com <ma...@gmail.com>> wrote:
>
>                 I'm trying to use Olingo to connect to an Odata v4
>                 service from Android. I'm having a bit of trouble
>                 getting the filter to work
>
>                 I've tested it with the Northwind sample and the URI
>                 that gets produce works in a browser:
>
>                 http://services.odata.org/Experimental/Northwind/Northwind.svc/Customers?%24filter=%28CustomerID+eq+%27ALFKI%27%29
>
>                 I always get the following error:
>                 =============================
>                 java.lang.IllegalArgumentException:
>                 org.apache.olingo.commons.api.serialization.ODataDeserializerException:
>                 com.fasterxml.jackson.core.JsonParseException:
>                 Expected OData Entity, found EntitySet
>                 =============================
>
>                 I'm using this code:
>
>                 =============================
>                 String serviceUrl =
>                 "http://services.odata.org/Experimental/Northwind/Northwind.svc";
>                 String entity = "Customers";
>                 String filter = "CustomerID";
>                 String id = "ALFKI";
>
>                 try {
>                 final ODataEntityRequest<ODataEntity> jsonReq =
>                 client.getRetrieveRequestFactory().
>                 getEntityRequest(client.newURIBuilder(serviceUrl).
>                 appendEntitySetSegment(entity)
>                 .filter(client.getFilterFactory().eq(filter,id)).build());
>
>                 Log.v(TAG, "URI: " + jsonReq.getURI());
>
>                 final ODataEntity spammer =
>                 jsonReq.execute().getBody(); //blows up here
>                 =============================
>
>                 how do I get the filter to work??
>
>                 Thanks
>
>


-- 
Fabio Martelli

Tirasa - Open Source Excellence
http://www.tirasa.net/

Apache Syncope PMC
http://people.apache.org/~fmartelli/


Re: Expected OData Entity, found EntitySet

Posted by Jonathan Peterson <jo...@gmail.com>.
I don't think I really need proxy classes for this project. In this case,
I'm going to be making the same request with a different ID to get one
property from the feed.

I looked at the Android tutorial already, however there's no simple "get
where this is that" sample (which is really weird)

I try the .filter(" CustomerID eq 'ALFKI' ") I still get the same error as
before. "Expected OData Entity, found EntitySet"

On Tue Oct 28 2014 at 6:06:41 AM Alex Maiereanu <al...@3sstudio.com>
wrote:

> 1, you should actually try to use the proxy classes. It will save you a
> lot of pain.
> 2, I didnt use the RequestFactory that much, so i'm guessing right now. We
> also had some issue with the filter factory, and ended up just to use some
> strings. In your case
>
> .filter(" CustomerID eq 'ALFKI' ")
>
> Also have a look here
>
>
> https://github.com/Tirasa/olingoClientOnAndroidSample/blob/master/src/main/java/net/tirasa/olingo4android/Main.java
>
> If you need help with generating the proxy classes, I can help you with
> that
>
>
>  Salutari din Brasov /  Greetings from Brasov
>
> Alex-Paul Maiereanu
>
> +40 761 684 212
>
> www.3sstudio.com
>
> Facebook <https://www.facebook.com/smartsocialsoftware> Twitter
> <https://twitter.com/SmartSocialSoft> Google+
> <https://plus.google.com/101299629750815349588/posts>
>
> On Tue, Oct 28, 2014 at 12:20 AM, Jonathan Peterson <jo...@gmail.com>
> wrote:
>
>> 1) nope I'm not using proxy classes.
>>
>> 2)  I've added
>>
>> FilterFactory filterFactory = client.getFilterFactory();
>>
>>  I've changed my filter to
>>
>>
>> .filter(filterFactory.eq(filterFactory.getArgFactory().property(filter),filterFactory.getArgFactory().property(id))).build());
>>
>> and I get:
>>
>>  Could not find a property named 'ALFKI' on type 'NorthwindModel.Customer'
>>
>> if I change "id" to
>>
>> id = "%27ALFKI%27";
>>
>> I'm back to the error message I was at before.
>>
>> I'm only trying to retrieve one record here.
>>
>> On Mon Oct 27 2014 at 5:14:47 PM Alex Maiereanu <
>> alex.maiereanu@3sstudio.com> wrote:
>>
>>> Hey Jonathan,
>>>
>>> 1.Are you using the proxy class? Those generated classes will save a lot
>>> of time.
>>>
>>> 2 as for the uri builder,  you can have a look in the framework unit
>>> test to see how stuff works.  Here is a test for filtering.
>>>
>>>
>>> https://github.com/apache/olingo-odata4/blob/master/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java
>>> On Oct 27, 2014 10:34 PM, "Jonathan Peterson" <jo...@gmail.com> wrote:
>>>
>>>> I'm trying to use Olingo to connect to an Odata v4 service from
>>>> Android. I'm having a bit of trouble getting the filter to work
>>>>
>>>> I've tested it with the Northwind sample and the URI that gets produce
>>>> works in a browser:
>>>>
>>>>
>>>> http://services.odata.org/Experimental/Northwind/Northwind.svc/Customers?%24filter=%28CustomerID+eq+%27ALFKI%27%29
>>>>
>>>> I always get the following error:
>>>> =============================
>>>> java.lang.IllegalArgumentException:
>>>> org.apache.olingo.commons.api.serialization.ODataDeserializerException:
>>>> com.fasterxml.jackson.core.JsonParseException: Expected OData Entity, found
>>>> EntitySet
>>>> =============================
>>>>
>>>> I'm using this code:
>>>>
>>>> =============================
>>>> String serviceUrl = "
>>>> http://services.odata.org/Experimental/Northwind/Northwind.svc";
>>>> String entity = "Customers";
>>>> String filter = "CustomerID";
>>>> String id = "ALFKI";
>>>>
>>>> try {
>>>> final ODataEntityRequest<ODataEntity> jsonReq =
>>>> client.getRetrieveRequestFactory().
>>>> getEntityRequest(client.newURIBuilder(serviceUrl).
>>>> appendEntitySetSegment(entity)
>>>> .filter(client.getFilterFactory().eq(filter,id)).build());
>>>>
>>>> Log.v(TAG, "URI: " + jsonReq.getURI());
>>>>
>>>> final ODataEntity spammer = jsonReq.execute().getBody(); //blows up here
>>>> =============================
>>>>
>>>> how do I get the filter to work??
>>>>
>>>> Thanks
>>>>
>>>
>

Re: Expected OData Entity, found EntitySet

Posted by Alex Maiereanu <al...@3sstudio.com>.
1, you should actually try to use the proxy classes. It will save you a lot
of pain.
2, I didnt use the RequestFactory that much, so i'm guessing right now. We
also had some issue with the filter factory, and ended up just to use some
strings. In your case

.filter(" CustomerID eq 'ALFKI' ")

Also have a look here

https://github.com/Tirasa/olingoClientOnAndroidSample/blob/master/src/main/java/net/tirasa/olingo4android/Main.java

If you need help with generating the proxy classes, I can help you with that


 Salutari din Brasov /  Greetings from Brasov

Alex-Paul Maiereanu

+40 761 684 212

www.3sstudio.com

Facebook <https://www.facebook.com/smartsocialsoftware> Twitter
<https://twitter.com/SmartSocialSoft> Google+
<https://plus.google.com/101299629750815349588/posts>

On Tue, Oct 28, 2014 at 12:20 AM, Jonathan Peterson <jo...@gmail.com>
wrote:

> 1) nope I'm not using proxy classes.
>
> 2)  I've added
>
> FilterFactory filterFactory = client.getFilterFactory();
>
>  I've changed my filter to
>
>
> .filter(filterFactory.eq(filterFactory.getArgFactory().property(filter),filterFactory.getArgFactory().property(id))).build());
>
> and I get:
>
>  Could not find a property named 'ALFKI' on type 'NorthwindModel.Customer'
>
> if I change "id" to
>
> id = "%27ALFKI%27";
>
> I'm back to the error message I was at before.
>
> I'm only trying to retrieve one record here.
>
> On Mon Oct 27 2014 at 5:14:47 PM Alex Maiereanu <
> alex.maiereanu@3sstudio.com> wrote:
>
>> Hey Jonathan,
>>
>> 1.Are you using the proxy class? Those generated classes will save a lot
>> of time.
>>
>> 2 as for the uri builder,  you can have a look in the framework unit test
>> to see how stuff works.  Here is a test for filtering.
>>
>>
>> https://github.com/apache/olingo-odata4/blob/master/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java
>> On Oct 27, 2014 10:34 PM, "Jonathan Peterson" <jo...@gmail.com> wrote:
>>
>>> I'm trying to use Olingo to connect to an Odata v4 service from Android.
>>> I'm having a bit of trouble getting the filter to work
>>>
>>> I've tested it with the Northwind sample and the URI that gets produce
>>> works in a browser:
>>>
>>>
>>> http://services.odata.org/Experimental/Northwind/Northwind.svc/Customers?%24filter=%28CustomerID+eq+%27ALFKI%27%29
>>>
>>> I always get the following error:
>>> =============================
>>> java.lang.IllegalArgumentException:
>>> org.apache.olingo.commons.api.serialization.ODataDeserializerException:
>>> com.fasterxml.jackson.core.JsonParseException: Expected OData Entity, found
>>> EntitySet
>>> =============================
>>>
>>> I'm using this code:
>>>
>>> =============================
>>> String serviceUrl = "
>>> http://services.odata.org/Experimental/Northwind/Northwind.svc";
>>> String entity = "Customers";
>>> String filter = "CustomerID";
>>> String id = "ALFKI";
>>>
>>> try {
>>> final ODataEntityRequest<ODataEntity> jsonReq =
>>> client.getRetrieveRequestFactory().
>>> getEntityRequest(client.newURIBuilder(serviceUrl).
>>> appendEntitySetSegment(entity)
>>> .filter(client.getFilterFactory().eq(filter,id)).build());
>>>
>>> Log.v(TAG, "URI: " + jsonReq.getURI());
>>>
>>> final ODataEntity spammer = jsonReq.execute().getBody(); //blows up here
>>> =============================
>>>
>>> how do I get the filter to work??
>>>
>>> Thanks
>>>
>>

Re: Expected OData Entity, found EntitySet

Posted by Jonathan Peterson <jo...@gmail.com>.
1) nope I'm not using proxy classes.

2)  I've added

FilterFactory filterFactory = client.getFilterFactory();

 I've changed my filter to

.filter(filterFactory.eq(filterFactory.getArgFactory().property(filter),filterFactory.getArgFactory().property(id))).build());

and I get:

 Could not find a property named 'ALFKI' on type 'NorthwindModel.Customer'

if I change "id" to

id = "%27ALFKI%27";

I'm back to the error message I was at before.

I'm only trying to retrieve one record here.

On Mon Oct 27 2014 at 5:14:47 PM Alex Maiereanu <al...@3sstudio.com>
wrote:

> Hey Jonathan,
>
> 1.Are you using the proxy class? Those generated classes will save a lot
> of time.
>
> 2 as for the uri builder,  you can have a look in the framework unit test
> to see how stuff works.  Here is a test for filtering.
>
>
> https://github.com/apache/olingo-odata4/blob/master/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java
> On Oct 27, 2014 10:34 PM, "Jonathan Peterson" <jo...@gmail.com> wrote:
>
>> I'm trying to use Olingo to connect to an Odata v4 service from Android.
>> I'm having a bit of trouble getting the filter to work
>>
>> I've tested it with the Northwind sample and the URI that gets produce
>> works in a browser:
>>
>>
>> http://services.odata.org/Experimental/Northwind/Northwind.svc/Customers?%24filter=%28CustomerID+eq+%27ALFKI%27%29
>>
>> I always get the following error:
>> =============================
>> java.lang.IllegalArgumentException:
>> org.apache.olingo.commons.api.serialization.ODataDeserializerException:
>> com.fasterxml.jackson.core.JsonParseException: Expected OData Entity, found
>> EntitySet
>> =============================
>>
>> I'm using this code:
>>
>> =============================
>> String serviceUrl = "
>> http://services.odata.org/Experimental/Northwind/Northwind.svc";
>> String entity = "Customers";
>> String filter = "CustomerID";
>> String id = "ALFKI";
>>
>> try {
>> final ODataEntityRequest<ODataEntity> jsonReq =
>> client.getRetrieveRequestFactory().
>> getEntityRequest(client.newURIBuilder(serviceUrl).
>> appendEntitySetSegment(entity)
>> .filter(client.getFilterFactory().eq(filter,id)).build());
>>
>> Log.v(TAG, "URI: " + jsonReq.getURI());
>>
>> final ODataEntity spammer = jsonReq.execute().getBody(); //blows up here
>> =============================
>>
>> how do I get the filter to work??
>>
>> Thanks
>>
>

Re: Expected OData Entity, found EntitySet

Posted by Alex Maiereanu <al...@3sstudio.com>.
Hey Jonathan,

1.Are you using the proxy class? Those generated classes will save a lot of
time.

2 as for the uri builder,  you can have a look in the framework unit test
to see how stuff works.  Here is a test for filtering.

https://github.com/apache/olingo-odata4/blob/master/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java
On Oct 27, 2014 10:34 PM, "Jonathan Peterson" <jo...@gmail.com> wrote:

> I'm trying to use Olingo to connect to an Odata v4 service from Android.
> I'm having a bit of trouble getting the filter to work
>
> I've tested it with the Northwind sample and the URI that gets produce
> works in a browser:
>
>
> http://services.odata.org/Experimental/Northwind/Northwind.svc/Customers?%24filter=%28CustomerID+eq+%27ALFKI%27%29
>
> I always get the following error:
> =============================
> java.lang.IllegalArgumentException:
> org.apache.olingo.commons.api.serialization.ODataDeserializerException:
> com.fasterxml.jackson.core.JsonParseException: Expected OData Entity, found
> EntitySet
> =============================
>
> I'm using this code:
>
> =============================
> String serviceUrl = "
> http://services.odata.org/Experimental/Northwind/Northwind.svc";
> String entity = "Customers";
> String filter = "CustomerID";
> String id = "ALFKI";
>
> try {
> final ODataEntityRequest<ODataEntity> jsonReq =
> client.getRetrieveRequestFactory().
> getEntityRequest(client.newURIBuilder(serviceUrl).
> appendEntitySetSegment(entity)
> .filter(client.getFilterFactory().eq(filter,id)).build());
>
> Log.v(TAG, "URI: " + jsonReq.getURI());
>
> final ODataEntity spammer = jsonReq.execute().getBody(); //blows up here
> =============================
>
> how do I get the filter to work??
>
> Thanks
>