[
https://issues.apache.org/jira/browse/OLINGO-844?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15089315#comment-15089315
]
Sushil commented on OLINGO-844:
-------------------------------
Hi Christian,
Thanks for the reply.
I am not worried about pretty printing. For sake of scenario understanding I
mentioned. Also I am passing values to all not nullable properties. Service
that I am using is not build using the Apache olingo.
I debugged the Apache source and here are findings :
When I Build the Properties as follows:
EntityProviderWriteProperties properties =
EntityProviderWriteProperties.serviceRoot(rootUri).build()
when I execute this line omitJsonWrapper and contentOnly Boolean attributes of
EntityProviderWriteProperties got sets to false and these values are being
used in JsonEntryEntityProducer class.
In the method JsonEntryEntityProducer .append at line 74 its checking for
!properties.isOmitJsonWrapper() which is true and its adding JSON wrapper which
I don't need.
Also in the same method at line 80 there is check !properties.isContentOnly()
which is true and its writing the metadata which is required.
again at line 86 same check !properties.isContentOnly() is present which is
true and writing the navigation properties which I don't need at all.
in short
1) I don't need JSON wrapper : at line 74 !properties.isOmitJsonWrapper()
Actual value : True
Expected Value is False
2) Need to write metadata : at line 80 !properties.isContentOnly()
Actual value : True
Expected Value is True
3) I don't need to calculate navigation properties : at line 86
!properties.isContentOnly()
Actual value : True
Expected Value is false
If I met three conditions I am getting proper JSON object and service call will
be successful. is there any way to set/reset these two Boolean variables ?
In case need more input please do let me know. thank you for help.
Regards,
Sushil
> While Inserting New Entity Getting BAD REQUEST as response from ODATA Service
> -----------------------------------------------------------------------------
>
> Key: OLINGO-844
> URL: https://issues.apache.org/jira/browse/OLINGO-844
> Project: Olingo
> Issue Type: Bug
> Components: odata2-core
> Affects Versions: V2 2.0.0, V2 2.0.5
> Environment: Windows 10 Operating System
> Reporter: Sushil
> Assignee: Christian Amend
> Priority: Blocker
> Labels: newbie
>
> Hi All,
> I am Using 2.0.0 client version to call ODATA Service. When we invoke
> respective API to insert record we are getting Error 400 - BAD REQUEST.
> 1) Its Secured ODATA Service : we made sure that authorization header is
> added to request.
> 2) We added properties of Entity using Map <String, Obejct> and we can see
> that those are properly set in JSON object while pushing the data.
> 3) URL is correctly formed : First we tested the URL with SOAPUI with test
> JSON object, Entity is properly get saved and we got Http Response as 201 -
> Created.
> 4) While Calling the same ODATA Service API by using Olingo
> contentType = Application/Json
> entitySet = SomeEntityName
> data = map<String,Object > with properties of SomeEntity
> properties = EntityProviderWriteProperties.serviceRoot(rootUri).build();
> ODataResponse response = EntityProvider.writeEntry(contentType, entitySet,
> data, properties);
> After getting the response we retrieved the entity from response as follows :
> 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");
> when we print the absolutUri : its correct as that of SOAPUI we tested.
> Content = JSON object that we are posting is not formed correctly as that
> SOAP UI when we print the JSON object its look like as follows :
> Here Entity Name is "SomeEntity"
> {
> "d": {
> "__metadata": {
> "id": "SomeEntitySomeEntity('SomeEntityUser')",
> "uri": "SomeEntitySomeEntity('SomeEntityUser')",
> "type": "SFOData.SomeEntity"
> },
> "addressLine1": null,
> "addressLine2": null,
> "addressLine3": null,
> "userId": "SomeEntityUser",
> "username": "SomeEntityUser",
> "zipCode": null,
> }
> }
> as we can see that this object is not formed correctly We are suspecting we
> as result we are getting 400 BAD REQUEST response from ODATA Service.
> formation of JSON object is taking care by olingo Library.
> Please guide us on this issue.
> Thanks !
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)