Search code examples
odataolingo

Error in exposing an Entity with ODataService


while I'm Passing an entity in the URL its saying ...
Could not find an entity set or function import for 'Books'.

I'm trying to expose an "ODataService" of book and publisher in Java. Code is very long. so can you suggest me what might be the possible cause for this??


Solution

  • I guess that you didn't define an entity set (Books) for an entity type (Book for example) within your EDM provider. To check this, you can have the look at the root URL of your service (for example http://services.odata.org/V4/OData/OData.svc/). I think that, in your case, no collection entry is defined for Books :

    <service xmlns="http://www.w3.org/2007/app"  
             xmlns:atom="http://www.w3.org/2005/Atom"  
             xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" 
             xml:base="http://services.odata.org/V4/OData/OData.svc/"  
             m:context="http://services.odata.org/V4/OData/OData.svc/$metadata">
        <workspace>
            <atom:title type="text">Default</atom:title>
            <collection href="Books">
                <atom:title type="text">Books</atom:title>
            </collection>
            (...)
        </workspace>
    </service>
    

    You could also check if an entity type is defined of type Book. See a link like that http://services.odata.org/V4/OData/OData.svc/$metadata.

    <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" 
               Version="4.0">
        <edmx:DataServices>
            <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" 
                    Namespace="ODataDemo">
                <EntityType Name="Book">
                (...)
                </EntityType>
            </Schema>
        </edmx:DataServices>
    </edmx:Edmx>
    

    The following link provides you a comprehensive description of how to implement an OData service with Olingo v4:

    https://templth.wordpress.com/2015/04/27/implementing-an-odata-service-with-olingo/

    See section "Implementing a custom EdmProvider" to see how to implement an EDM provider with Olingo.

    Hope it will help you, Thierry