Archana created OLINGO-1040:
-------------------------------

             Summary: Insert /Update operation fails with 400 bad request
                 Key: OLINGO-1040
                 URL: https://issues.apache.org/jira/browse/OLINGO-1040
             Project: Olingo
          Issue Type: Bug
          Components: odata4-client
    Affects Versions: (Java) V4 4.3.0
            Reporter: Archana


Hi ,
I am using Olingo 4.3.0 client core api and trying to do CUD operations.
I am able to do select /delete operations but my insert and update code fails 
throwing 400 bad request.
I was able to see my POST request and header but not sure if the body is sent 
correctly.Here's code snippet I used:

URI insertUri = coreclient.newURIBuilder(serviceRoot)
                                .appendEntitySetSegment("contacts").build();

ClientEntity contact = coreclient.getObjectFactory().newEntity(
                                new 
FullQualifiedName("Microsoft.Dynamics.CRM.contact"));

contact.getProperties().add(
                                
coreclient.getObjectFactory().newPrimitiveProperty(
                                                "firstname",
                                                coreclient.getObjectFactory()
                                                                
.newPrimitiveValueBuilder()
                                                                
.buildString("InsertTest")));
contact.getProperties().add(
                                
coreclient.getObjectFactory().newPrimitiveProperty(
                                                "lastname",
                                                coreclient.getObjectFactory()
                                                                
.newPrimitiveValueBuilder()
                                                                
.buildString("InsertTestlastname")));

ODataEntityCreateRequest<ClientEntity> req = coreclient                 
.getCUDRequestFactory().getEntityCreateRequest(insertUri,contact);

System.out.println(req.execute().getStatusCode());


I get below exception :

Exception in thread "main" 
org.apache.olingo.client.api.communication.ODataClientErrorException: entity 
[HTTP/1.1 400 Bad Request]
        at 
org.apache.olingo.client.core.communication.header.ODataErrorResponseChecker.checkResponse(ODataErrorResponseChecker.java:75)
        at 
org.apache.olingo.client.core.communication.request.AbstractRequest.checkResponse(AbstractRequest.java:54)
        at 
org.apache.olingo.client.core.communication.request.AbstractODataRequest.doExecute(AbstractODataRequest.java:310)
        at 
org.apache.olingo.client.core.communication.request.cud.ODataEntityCreateRequestImpl.execute(ODataEntityCreateRequestImpl.java:88)
        at 
org.apache.olingo.client.core.communication.request.cud.ODataEntityCreateRequestImpl.execute(ODataEntityCreateRequestImpl.java:47)

Can anyone please assist?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to