It's all about the answers!

Ask a question

https://localhost:9443/jts/process/project-areas


S M (8622023) | asked Oct 10 '11, 4:55 p.m.
I'm trying to use this REST webservice, but I'm not sure what I should use as Content-Type and Accept in the request header.

If I'm using it without any request header, then I get the php code of the homepage back. So how can I check what request header I should set?

In this document, it is mentioned application/xml, but that doesnt improve the situation.

https://jazz.net/wiki/bin/view/Main/DraftTeamProcessRestApi#GET_project_areas_collection

8 answers



permanent link
Martha (Ruby) Andrews (3.0k44351) | answered Oct 10 '11, 9:15 p.m.
JAZZ DEVELOPER
Hello,

This is what we use in the tests for that service:
Content-Type is application/xml;charset=UTF-8
Accept-Charset is UTF-8
Accept is application/xml

Regards,
Martha

I'm trying to use this REST webservice, but I'm not sure what I should use as Content-Type and Accept in the request header.

If I'm using it without any request header, then I get the php code of the homepage back. So how can I check what request header I should set?

In this document, it is mentioned application/xml, but that doesnt improve the situation.

https://jazz.net/wiki/bin/view/Main/DraftTeamProcessRestApi#GET_project_areas_collection

permanent link
S M (8622023) | answered Oct 11 '11, 4:57 a.m.
Thanks for your answer. I tried everthing that you suggested, but I still don't get the correct result:

public void getRootService() throws ClientProtocolException, IOException {

DefaultHttpClient client = new DefaultHttpClient();

HttpGet httpGet = new HttpGet("https://localhost:9443/ccm/rootservices");
httpGet.setHeader("Accept", "text/xml");
HttpResponse response = client.execute(httpGet, localContext);
HttpEntity entity = response.getEntity();
InputStream in = entity.getContent();
String projectURL = XMLDocumentParser.parseDocument(in);

System.out.println(projectURL);
HttpGet getProjectsRequest = new HttpGet(projectURL);
getProjectsRequest.setHeader("Content-Type", "application/xml, charset=UTF-8");
getProjectsRequest.setHeader("Accept-Charset", "UTF-8");
getProjectsRequest.setHeader("Accept", "application/xml");

ResponseHandler<String> handler = new BasicResponseHandler();
String projectResponse = client.execute(getProjectsRequest, handler, localContext);

System.out.println(projectResponse);

}


This generates the following result:

{

"userId": "TestUser",
"roles": [
"JazzUsers",
"JazzAdmins"]
}


But if I use a REST Client plugin for firefox, I get the correct results with the same headers.

I can't see an error in my code.

permanent link
Dancy Xia (11632) | answered Oct 11 '11, 7:45 a.m.
Thanks for your answer. I tried everthing that you suggested, but I still don't get the correct result:

This generates the following result:

{

"userId": "TestUser",
"roles": [
"JazzUsers",
"JazzAdmins"]
}



This response looks like the json response to a user query. Are you sure the projectURL returned from the xml parser is like this: https://localhost:9443/jts/process/project-areas?

Dancy

permanent link
S M (8622023) | answered Oct 11 '11, 7:48 a.m.
Thanks for your answer. I tried everthing that you suggested, but I still don't get the correct result:

This generates the following result:

{

"userId": "TestUser",
"roles": [
"JazzUsers",
"JazzAdmins"]
}



This response looks like the json response to a user query. Are you sure the projectURL returned from the xml parser is like this: https://localhost:9443/jts/process/project-areas?

Dancy

Yes I am sure. If I test this URL with a REST plugin for firefox it returns the correct XML document.

permanent link
Dancy Xia (11632) | answered Oct 11 '11, 11:06 a.m.
Yes I am sure. If I test this URL with a REST plugin for firefox it returns the correct XML document.

Can you try to get the status code? And have you passed the authentication?

permanent link
S M (8622023) | answered Oct 11 '11, 11:34 a.m.
Yes I am sure. If I test this URL with a REST plugin for firefox it returns the correct XML document.


Can you try to get the status code? And have you passed the authentication?

The status Code is 200. And I think that I have passed the authentication.

I have the following cookies after the authentication:

JSESSIONID : 5AB83AF30B70DDC12F8583541C8A393E

JazzFormAuth : Form


And this is the header of the subsequent test GET to the REST:

Server: Apache-Coyote/1.1

Cache-Control: private
Expires: Thu, 01 Jan 1970 01:00:00 CET
Set-Cookie: JSESSIONIDSSO=9A492E254F51CCC6DDF0A69CB5EE4D57; Path=/; Secure
Set-Cookie: X-com-ibm-team-foundation-auth-loop-avoidance=false
Content-Type: text/json;charset=utf-8
Content-Length: 76
Date: Tue, 11 Oct 2011 15:44:07 GMT

permanent link
Martha (Ruby) Andrews (3.0k44351) | answered Oct 12 '11, 8:15 p.m.
JAZZ DEVELOPER
Hello,

I am not sure if it matters, but our tests are also setting a header named
X-com-ibm-team-userid to the user id.

Martha
Yes I am sure. If I test this URL with a REST plugin for firefox it returns the correct XML document.


Can you try to get the status code? And have you passed the authentication?

The status Code is 200. And I think that I have passed the authentication.

I have the following cookies after the authentication:

JSESSIONID : 5AB83AF30B70DDC12F8583541C8A393E

JazzFormAuth : Form


And this is the header of the subsequent test GET to the REST:

Server: Apache-Coyote/1.1

Cache-Control: private
Expires: Thu, 01 Jan 1970 01:00:00 CET
Set-Cookie: JSESSIONIDSSO=9A492E254F51CCC6DDF0A69CB5EE4D57; Path=/; Secure
Set-Cookie: X-com-ibm-team-foundation-auth-loop-avoidance=false
Content-Type: text/json;charset=utf-8
Content-Length: 76
Date: Tue, 11 Oct 2011 15:44:07 GMT

permanent link
Dancy Xia (11632) | answered Oct 13 '11, 10:02 p.m.
Yes I am sure. If I test this URL with a REST plugin for firefox it returns the correct XML document.


Can you try to get the status code? And have you passed the authentication?

The status Code is 200. And I think that I have passed the authentication.

I have the following cookies after the authentication:

JSESSIONID : 5AB83AF30B70DDC12F8583541C8A393E

JazzFormAuth : Form


And this is the header of the subsequent test GET to the REST:

Server: Apache-Coyote/1.1

Cache-Control: private
Expires: Thu, 01 Jan 1970 01:00:00 CET
Set-Cookie: JSESSIONIDSSO=9A492E254F51CCC6DDF0A69CB5EE4D57; Path=/; Secure
Set-Cookie: X-com-ibm-team-foundation-auth-loop-avoidance=false
Content-Type: text/json;charset=utf-8
Content-Length: 76
Date: Tue, 11 Oct 2011 15:44:07 GMT


Have you tried setting these cookies in the request header? I don't see this in your code. And you may need to pass SSO session id as well.

Dancy

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.