Problem with REST in Java
I am trying to update workitems via the REST api, using Java
I refered to the following line in the documentation:
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);HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
httpCon.setDoOutput(true);
httpCon.setRequestMethod("PUT");
httpCon.setRequestProperty("Cookie", cookie);
httpCon.setRequestProperty("If-Match", e_Tag);
httpCon.setRequestProperty("Content-Type", "application/x-oslc-cm-change-request+xml");
httpCon.setRequestProperty("Accept", "application/x-oslc-cm-change-request+xml");
OutputStreamWriter out = new OutputStreamWriter(httpCon.getOutputStream(), "UTF-8");
out.write(document);
out.close();
System.out.println(httpCon.getResponseCode()+"="+httpCon.getResponseMessage());
What am I doing wrong?
Thanks
Marco
Accepted answer
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?
Comments
One other answer
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.