It's all about the answers!

Ask a question

Java & REST API question

Karthik Krishnan (8825115162) | 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/

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

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?

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");

Accepted answer

permanent link
Rosa Naranjo (2.9k11623) | answered Apr 30 '14, 10:26 a.m.
There are Java samples in the OSLC workshop
Karthik Krishnan selected this answer as the correct answer

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.