You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "Christian Amend (JIRA)" <ji...@apache.org> on 2016/01/07 15:12:39 UTC

[jira] [Commented] (OLINGO-844) While Inserting New Entity Getting BAD REQUEST as response from ODATA Service

    [ https://issues.apache.org/jira/browse/OLINGO-844?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15087396#comment-15087396 ] 

Christian Amend commented on OLINGO-844:
----------------------------------------

Hi Sushil,

in Olingo we perform no pretty printing/formatting in any form. We just write the content to the stream without any whitespaces or line breaks. Line braks like this can happen if the streamToArray method has a bug. 
Could it be that you set properties to null that are not nullable according to the metadata and that is why it fails? If the service you are using is developed by you using Olingo you can turn on the debug information as described here: http://olingo.apache.org/doc/odata2/tutorials/debug.html to get more information why you get a Bad Request.

Best Regards,
Christian

> 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)