It's all about the answers!

Ask a question

Java & REST API question


Karthik Krishnan (8744104154) | asked Apr 30 '14, 9:30 a.m.
I am writing a Java program which will get the xml of a workitem. After authentication when I try to get the work item (https://localhost:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/99.xml)

and I always get the user info in json format as descried here 

https://jazz.net/forum/questions/64839/httpslocalhost9443jtsprocessproject-areas

I am using http client 4.3.3 

I am able to get xml using curl as well as REST client for Firefox

Anyone has any idea why I get my user info in json format?



Comments
Canberk Akduygu commented Apr 30 '14, 10:10 a.m.

Which headers are you including to your rest call?
Accept = application/xml or aaplication/json

I also see that you add .xml at the end of your url. You dont need to do that.


Karthik Krishnan commented Apr 30 '14, 10:18 a.m.

I already have it


These are my headers

httpget.addHeader("Accept", "application/xml");
httpget.addHeader("Content-Type","application/xml, charset=UTF-8");
httpget.addHeader("Accept-Charset","UTF-8") 

Accepted answer


permanent link
Rosa Naranjo (2.9k11423) | answered Apr 30 '14, 10:26 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Karthik
There are Java samples in the OSLC workshop https://jazz.net/library/article/635
Karthik Krishnan selected this answer as the correct answer

Comments
Karthik Krishnan commented Apr 30 '14, 11:02 a.m.

Thanks. I tried the example and it worked. I have no idea what is wrong with my code as it is almost identical except that I am using HTTP Client 4.3.3. 


thanks anyway

Your answer


Register or to post your answer.