How to resolve Issues while writing work Environment data's in RTC using REST service POST/PUT?
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
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
Sep 15 '16, 2:21 a.m.Hi Donald,
Donald Nong
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.