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

Sushil commented on OLINGO-844:
-------------------------------

Hi Christian,

thanks for reply.

it was very helpful to know the how to set and reset above mentioned flags. but 
as earlier stated  I have to met all 3 conditions so as to create proper 
request object and to get successful response.

As requested please find below the sample payloads

1)Working Sample payload :

Request JSON Object : 
{"__metadata":{"id":"User('TestUser122')","uri":"User('TestUser122')","type":"SFOData.User"},"firstName":"TestUser122","lastName":"TestUser122","status":"Active","userId":"TestUser122","username":"TestUser122"}

once we post this payload below is the response getting from service 

 {
"d" : [
{
"key" : "TestUser122", "status" : "OK", "editStatus" : "INSERTED", "message" : 
null, "index" : 0, "httpCode" : 201, "inlineResults" : null
}
]
}


2) Not Working Payload : 

I did  
EntityProviderWriteProperties properties = 
EntityProviderWriteProperties.serviceRoot(rootUri).contentOnly(false).omitJsonWrapper(true).build();

I didn't met both the conditions  2, 3  so I am getting below request Json 
object

{"__metadata":{"id":"User('TestUser122')","uri":"User('TestUser122')","type":"SFOData.User"},"firstName":"Test
 TestUser122","lastName":"Test 
TestUser122","status":"Active","userId":"TestUser122","username":"TestUser122","customManager":{"__deferred":{"uri":"User('TestUser122')/customManager"}},"customReports":{"__deferred":{"uri":"User('TestUser122')/customReports"}},"directReports":{"__deferred":{"uri":"User('TestUser122')/directReports"}},"hr":{"__deferred":{"uri":"User('TestUser122')/hr"}},"hrReports":{"__deferred":{"uri":"User('TestUser122')/hrReports"}},"manager":{"__deferred":{"uri":"User('TestUser122')/manager"}},"matrixManager":{"__deferred":{"uri":"User('TestUser122')/matrixManager"}},"matrixReports":{"__deferred":{"uri":"User('TestUser122')/matrixReports"}},"proxy":{"__deferred":{"uri":"User('TestUser122')/proxy"}},"secondManager":{"__deferred":{"uri":"User('TestUser122')/secondManager"}},"secondReports":{"__deferred":{"uri":"User('TestUser122')/secondReports"}}}


after posting this request I am getting below response :

 {
"d" : [
{
"key" : null, "status" : "ERROR", "editStatus" : null, "message" : "bad 
valueString [('TestUser122')/customManager] as part of keyString 
[('TestUser122')/customManager]", "index" : 0, "httpCode" : 500, 
"inlineResults" : null
}
]
}

I do see that conditions 2,3 bot are not met as result  deferred properties got 
appended to input json object.

Please guide me on this issue.

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

Reply via email to