0
votes

I am using apache olingo 2.0 as client so as to access the ODATA service. I am successfully able to get metadata for particular entity. I was able to read feed using

EntityProvider.readFeed(contentType,
        entityContainer.getEntitySet(entitySetName),
        content,
        EntityProviderReadProperties.init().build());

Problem pops up when I am trying to write the entry

 ODataResponse response = EntityProvider.writeEntry(contentType, entitySet, data, properties);

here contentType= Application\Json

entitySet = Entity set retrieved from EDM (metadata)

 data = data is map Map<String,object> with added property name and value.

when creating entry using this api ODataResponse response = EntityProvider.writeEntry(contentType, entitySet, data, properties);

I am getting Error 400 - Bad Request also when I print the content by using

Object entity = response.getEntity();
    if (entity instanceof InputStream) {
      byte[] buffer = streamToArray((InputStream) entity);
      // just for logging
      String content = new String(buffer);
      print(httpMethod + " request on uri '" + absolutUri + "' with content:\n  " + content + "\n");

  I do see that input object is not formed correctly and I am unable to understand why since it is handle by olingo jars.

I am following same client tutorial at location

https://olingo.apache.org/doc/odata2/tutorials/OlingoV2BasicClientSample.html

I modified this client to call ODATA service present on Success factor ERP. I am just using client code from tutorial and modified to call ODATA service present on Success factor ERP.

1

1 Answers

0
votes

Set property omitJsonWrapper, and it should work. Replace the example code with below :

EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(rootUri).omitJsonWrapper(true).build();