Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

OData v4 in Java - how to post media content?

Former Member
0 Likes
699

I have done something similar like it is defined in this tutorial, so I have published one cds entity and try to build Java module with OData v4.

I can get the objects using GET resource and can even POST the object. However, this works only in case when I don't try to POST something to largeBinary field. I cannot reach the breakpoint inside my createObject method because I get the following error (400 Bad Request):

{
    "error": {
        "code": "OLINGO LIBRARY EXCEPTION",
        "message": "Invalid value for property 'content'."
    }
}

This is the case when I try to send String or encoded base64 string. In this case I don't come to my method (breakpoint).

However, when I send null it is reached even though I get another error (500 Internal Server Error):

{
    "error": {
        "code": "OLINGO LIBRARY EXCEPTION",
        "message": "while trying to invoke the method org.apache.olingo.commons.api.data.Property.getValue() of a null object returned from org.apache.olingo.commons.api.data.Entity.getProperty(java.lang.String)"
    }
}

After this post request brought me the object in database and I try to reach the content using myObjects("idOfObject")/$value and get the following error:

{
    "error": {
        "code": "OLINGO LIBRARY EXCEPTION",
        "message": "The resource 'EmailAttachment' is not a media resource. $value can only be applied on media resources."
    }
}

So, my question is:

How to pass binary data into Java customer exit?

P.s. The method where I have a breakpoint is annotated like this:

@ExtendDataProvider(entitySet = { "MyObject" }, requestTypes = RequestType.CREATE)

I have done something similar like it is defined in this tutorial, so I have published one cds entity and try to build Java module with OData v4.

I can get the objects using GET resource and can even POST the object. However, this works only in case when I don't try to POST something to largeBinary field. I cannot reach the breakpoint inside my createObject method because I get the following error (400 Bad Request):

{
    "error": {
        "code": "OLINGO LIBRARY EXCEPTION",
        "message": "Invalid value for property 'content'."
    }
}

This is the case when I try to send String or encoded base64 string. In this case I don't come to my method (breakpoint).

However, when I send null it is reached even though I get another error (500 Internal Server Error):

{
    "error": {
        "code": "OLINGO LIBRARY EXCEPTION",
        "message": "while trying to invoke the method org.apache.olingo.commons.api.data.Property.getValue() of a null object returned from org.apache.olingo.commons.api.data.Entity.getProperty(java.lang.String)"
    }
}

After this post request brought me the object in database and I try to reach the content using myObjects("idOfObject")/$value and get the following error:

{
    "error": {
        "code": "OLINGO LIBRARY EXCEPTION",
        "message": "The resource 'EmailAttachment' is not a media resource. $value can only be applied on media resources."
    }
}

So, my question is:

How to pass binary data into Java customer exit?

P.s. The method where I have a breakpoint is annotated like this:

@ExtendDataProvider(entitySet = { "MyObject" }, requestTypes = RequestType.CREATE)
0 REPLIES 0