<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic OData v4 in Java - how to post media content? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-v4-in-java-how-to-post-media-content/m-p/720102#M33541</link>
    <description>&lt;P&gt;I have done something similar like it is defined in &lt;A href="https://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/2.0.03/en-US/e09f5225d61b40bb8761c756f138f2b0.html"&gt;this tutorial&lt;/A&gt;, so I have published one cds entity and try to build Java module with OData v4.&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;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 &lt;STRONG&gt;largeBinary&lt;/STRONG&gt; field. I cannot reach the breakpoint inside my &lt;EM&gt;createObject&lt;/EM&gt; method because I get the following error (400 Bad Request):&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;{
    "error": {
        "code": "OLINGO LIBRARY EXCEPTION",
        "message": "Invalid value for property 'content'."
    }
}&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;This is the case when I try to send &lt;EM&gt;String &lt;/EM&gt;or &lt;EM&gt;encoded base64 string&lt;/EM&gt;. In this case I don't come to my method (breakpoint).&lt;/P&gt;
  &lt;P&gt;However, when I send &lt;EM&gt;null &lt;/EM&gt;it is reached even though I get another error (500 Internal Server Error):&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;{
    "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)"
    }
}&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;After this post request brought me the object in database and I try to reach the content using &lt;EM&gt;myObjects("idOfObject")/$value&lt;/EM&gt; and get the following error:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;{
    "error": {
        "code": "OLINGO LIBRARY EXCEPTION",
        "message": "The resource 'EmailAttachment' is not a media resource. $value can only be applied on media resources."
    }
}&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;So, my question is:&lt;/P&gt;
  &lt;P&gt;How to pass binary data into Java customer exit?&lt;/P&gt;
  &lt;P&gt;P.s. The method where I have a breakpoint is annotated like this:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;@ExtendDataProvider(entitySet = { "MyObject" }, requestTypes = RequestType.CREATE)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 18 Sep 2018 12:57:41 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2018-09-18T12:57:41Z</dc:date>
    <item>
      <title>OData v4 in Java - how to post media content?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-v4-in-java-how-to-post-media-content/m-p/720102#M33541</link>
      <description>&lt;P&gt;I have done something similar like it is defined in &lt;A href="https://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/2.0.03/en-US/e09f5225d61b40bb8761c756f138f2b0.html"&gt;this tutorial&lt;/A&gt;, so I have published one cds entity and try to build Java module with OData v4.&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;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 &lt;STRONG&gt;largeBinary&lt;/STRONG&gt; field. I cannot reach the breakpoint inside my &lt;EM&gt;createObject&lt;/EM&gt; method because I get the following error (400 Bad Request):&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;{
    "error": {
        "code": "OLINGO LIBRARY EXCEPTION",
        "message": "Invalid value for property 'content'."
    }
}&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;This is the case when I try to send &lt;EM&gt;String &lt;/EM&gt;or &lt;EM&gt;encoded base64 string&lt;/EM&gt;. In this case I don't come to my method (breakpoint).&lt;/P&gt;
  &lt;P&gt;However, when I send &lt;EM&gt;null &lt;/EM&gt;it is reached even though I get another error (500 Internal Server Error):&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;{
    "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)"
    }
}&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;After this post request brought me the object in database and I try to reach the content using &lt;EM&gt;myObjects("idOfObject")/$value&lt;/EM&gt; and get the following error:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;{
    "error": {
        "code": "OLINGO LIBRARY EXCEPTION",
        "message": "The resource 'EmailAttachment' is not a media resource. $value can only be applied on media resources."
    }
}&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;So, my question is:&lt;/P&gt;
  &lt;P&gt;How to pass binary data into Java customer exit?&lt;/P&gt;
  &lt;P&gt;P.s. The method where I have a breakpoint is annotated like this:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;@ExtendDataProvider(entitySet = { "MyObject" }, requestTypes = RequestType.CREATE)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Sep 2018 12:57:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/odata-v4-in-java-how-to-post-media-content/m-p/720102#M33541</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-09-18T12:57:41Z</dc:date>
    </item>
  </channel>
</rss>

