Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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

0 votes



8 answers

Permanent link
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

0 votes


Permanent link
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.

0 votes


Permanent link
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

0 votes


Permanent link
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.

0 votes


Permanent link
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?

0 votes


Permanent link
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

0 votes


Permanent link
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

0 votes


Permanent link
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

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Oct 10 '11, 4:55 p.m.

Question was seen: 5,717 times

Last updated: Oct 10 '11, 4:55 p.m.

Confirmation Cancel Confirm