It's all about the answers!

Ask a question

How to resolve Issues while writing work Environment data's in RTC using REST service POST/PUT?


ast java (45121) | asked Sep 15 '16, 12:40 a.m.
 Hi Team,

I am trying to update/create the work environment data of the user in RTC using REST service.

I had tried the below steps,

//Created the raw rest service client.
ITeamRawRestServiceClient rawRestServiceClient = teamRepository.getRawRestServiceClient();
   
String uriString = teamRepository.getRepositoryURI() +  "service/com.ibm.team.apt.internal.service.rest.IResourcePlanningRestService/workEnvironment?contributorId=XXXXXXXXXXXXXXXXXX";  //Just changed the contributor UUID. 
    
   URI uri = new URI(uriString);
   IRawRestClientConnection connection = rawRestServiceClient.getConnection(uri);
   connection.addRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   InputStream is = getInputStream(document);

//Trying to POST or PUT
      Response doPutResponse = connection.doPost(is, is.available(), "text/xml"); // connection.doPut(is, is.available(), "text/xml"); 

Once i execute the above line(POST/PUT) I am getting the below exception, 

com.ibm.team.repository.common.transport.TeamServiceException: CRJAZ2942E A request from this server to another server could not be completed. The other server returned a 400 HTTP error with this error text: Bad Request.
CRJAZ2942E A request from this server to another server could not be completed. The other server returned a 400 HTTP error with this error text: Bad Request.
at com.ibm.team.repository.transport.client.RemoteTeamServer.throwHttpClientError(RemoteTeamServer.java:2105)
at com.ibm.team.repository.transport.client.RemoteTeamServer.executeMethod(RemoteTeamServer.java:1296)
at com.ibm.team.repository.transport.client.RemoteTeamServer.executeMethod(RemoteTeamServer.java:1121)
at com.ibm.team.repository.transport.client.RestClientConnectionBase.executeMethod(RestClientConnectionBase.java:375)
at com.ibm.team.repository.transport.client.RestClientConnectionBase.doMethod(RestClientConnectionBase.java:211)
at com.ibm.team.repository.transport.client.RestClientConnectionBase.doPost(RestClientConnectionBase.java:165)
at com.ibm.team.repository.transport.client.TeamRawRestServiceClient$RawRestClientConnection.doPost(TeamRawRestServiceClient.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.ibm.team.repository.client.internal.ServiceInterfaceProxy.invokeServiceCall(ServiceInterfaceProxy.java:254)
at com.ibm.team.repository.client.internal.ServiceInterfaceProxy.invoke(ServiceInterfaceProxy.java:110)
at com.ibm.team.repository.client.internal.RawRestServiceClientProxy$RestClientConnectionProxy.invoke(RawRestServiceClientProxy.java:121)
at com.sun.proxy.$Proxy19.doPost(Unknown Source)
...........................................................

Is it correct way to create the URI string as i mentioned in the above code? 

Please let me know what i am doing wrong or how to resolve this issue?

Thanks in advance.

Comments
Donald Nong commented Sep 15 '16, 1:54 a.m.

Just note that you're using an internal API, so not much documentation or published information is available. Your best bet would be capture the network trace in a browser while doing the some operation and analyze what is being sent to the server.


ast java commented Sep 15 '16, 2:21 a.m.

 Hi Donald, 


Thanks for your comment. 

The trace which i showed is top level.

The internal api's are called from RTC api's (Means I didn't directly call those doPost(..). 

In my code I am calling the "TeamRawRestServiceClient" 's doPost (InputStream content, long contentLength, String contentType) method. (Sorry I don't have the traces for these calls)

As I am new to the REST services please let me know how I can debug it.


Donald Nong commented Sep 15 '16, 4:11 a.m.

The service that you tried with, "service/com.ibm.team.apt.internal.service.rest.IResourcePlanningRestService/workEnvironment", is an internal one.

Be the first one to answer this question!


Register or to post your answer.