Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
2 replies Latest Post - ‏2013-02-05T03:58:52Z by SystemAdmin
IBM Timur Markunin
IBM Timur Markunin
1 Post
ACCEPTED ANSWER

Pinned topic REST API: Response Status code:HTTP/1.1 401 Unauthorized

‏2012-07-11T07:24:15Z |
Hello,

I'm trying to access FP resources via REST API. I've succeed with Firefox REST Client but failed to write java code.
Here is snippet of my code that returns "HTTP/1.1 401 Unauthorized".
Could you please write what's wrong with authorization or provide sample code?

HttpClient client = new DefaultHttpClient();

AuthScope as = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT);
UsernamePasswordCredentials upc = new UsernamePasswordCredentials("administrator", "focalpoint");

((AbstractHttpClient) client).getCredentialsProvider().setCredentials(as, upc);

BasicHttpContext localContext = new BasicHttpContext();

BasicScheme basicAuth = new BasicScheme();
localContext.setAttribute("preemptive-auth", basicAuth);

HttpHost targetHost = new HttpHost("Kvhoclm1.delta.internal", 8080, "http");

HttpGet httpget = new HttpGet("http://Kvhoclm1.delta.internal:8080/fp/resources/workspaces/2/modules/13/elements/61/attributes/984");
httpget.setHeader("Content-Type", "application/xml");

response = client.execute(targetHost, httpget,localContext);

HttpEntity entity = response.getEntity();
Object content = EntityUtils.toString(entity);

System.out.println(content.toString());

-Thanks in advance
Updated on 2013-02-05T03:58:52Z at 2013-02-05T03:58:52Z by SystemAdmin
  • Shafeeq AM
    Shafeeq AM
    155 Posts
    ACCEPTED ANSWER

    Re: REST API: Response Status code:HTTP/1.1 401 Unauthorized

    ‏2012-07-13T14:44:48Z  in response to IBM Timur Markunin
    Hi,

    A good starting point is RESTAPIExamples.zip (a complete eclipse project) shipped with Product. On Installation its placed in <FP_HOME>/apiexamples/. The sample code works against 'IT Portfolio Configuration Template'. Refer http://publib.boulder.ibm.com/infocenter/rfphelp/v6r5/topic/com.ibm.rational.fp.api.doc/topics/r_restapi_doc.html

    Regards,
    Shafeeq
    • SystemAdmin
      SystemAdmin
      269 Posts
      ACCEPTED ANSWER

      Re: REST API: Response Status code:HTTP/1.1 401 Unauthorized

      ‏2013-02-05T03:58:52Z  in response to Shafeeq AM
      Please,Give me apiexample.zip then I can't access to installation.Thank you very much.