Problem with REST in Java
![]()
Marco Bormann (161●19●10)
| asked Oct 07 '10, 10:02 a.m.
edited Oct 12 '17, 10:27 p.m. by David Lafreniere (4.8k●7) I am trying to update workitems via the REST api, using Java
curl -D - -k -b $COOKIES -H "If-Match: _1am9cFm0Ed6ELJg2MQ68Kg" -H "Content-Type: application/x-oslc-cm-change-request+json" -H "Accept: application/x-oslc-cm-change-request+json" -X PUT --data-binary @wi-821.json $URL Now here is my translation to java, which returns a 400,bad request response URL url = new URL(Parameters.serverURL + pageURL); What am I doing wrong? Thanks Marco |
Accepted answer
![]()
Hard to say, what is the detailed message coming back with the 400 response?
In the CURL example you use JSON, in the Java one you use XML. Perhaps there is something different about the XML example using Java? David Lafreniere selected this answer as the correct answer
Comments Concerning the XML, I found it easier to treat the data i get from Jazz in XML; and it is faily esay. There are quite a few examples where +json is replaced by +xml
Just to make sure, using the exact same request URL and XML content, this works fine with CURL and not Java? Have you tried also in another client like Firefox add-ons: REST client or Poster? Thanks Steve, Poster gave me some trouble with the authorization ...
Now I get a "204, no content" message and no update has been done
if I fix the content-length in the header and then leave the body empty, it prompts an error, so it has to get the body somehow.
I found a workable solution. What I tried was to PUT the workitem as whole with changes using a path like "resource/itemName/com.ibm.team.workitem.WorkItem/1598" as URL, sending back the changed XML file as String. That did not work and still doesn't. But if I specify the properties that I change and thus reduce the list using an appendix like "?oslc_cm.properties=dc:title" in the URL, I still get a 204 message, but the changes are done.
showing 5 of 6
show 1 more comments
|
One other answer
![]()
Hi,
I have created the svn dump file, and now trying to import it to the RTC . I get the below error message. Error UUID Missing.. I have created a svnuser to jazz userid mapping . My userid has jazzadmin rights. Comments ![]() FORUM MODERATOR / JAZZ DEVELOPER
Could you post the complete error including the stacktrace? It should be Hi, |