Rally Software

 View Only

 HTTP/1.1 401 Full authentication is required to access this resource

trupti gore's profile image
trupti gore posted Jan 26, 2021 06:29 PM
Hello,

I tried to run the CreateUpdateCard.java from Example provided under Java Tool kit for RestAPI. it throws me below error. I established HTTPURLConnection to authorize url and obtained the security key and used the same in below mentioned code.
Error:

Creating a story...
{"hierarchicalrequirement":{"Name":"Product OneShot Data Correction Request for USTEST","Project":"482545446960"}}
Exception in thread "main" java.io.IOException: HTTP/1.1 401 Full authentication is required to access this resource
at com.rallydev.rest.client.HttpClient.executeRequest(HttpClient.java:163)
at com.rallydev.rest.client.HttpClient.doRequest(HttpClient.java:145)
at com.rallydev.rest.client.ApiKeyClient.doRequest(ApiKeyClient.java:37)
at com.rallydev.rest.client.HttpClient.doPost(HttpClient.java:179)
at com.rallydev.rest.RallyRestApi.create(RallyRestApi.java:125)
at com.utility.main.qcutility.CreateUpdateStory.main(CreateUpdateStory.java:49)

But instead of using RestAPI, if I just make HttpURLConnection to the all the endpoints mentioned in steps and passing the key, my code works.
I wanted to make the restapi code work from example. Can someone help what wrong is happening here? This is the example codes from Javatoolkit.

RallyRestApi restApi = new RallyRestApi(new URI(host),strsecurityKey);
restApi.setApplicationName(applicationName);
CreateRequest createRequest = new CreateRequest("hierarchicalrequirement", newStory);
System.out.println(createRequest.getBody());
CreateResponse createResponse = restApi.create(createRequest);
System.out.println(createResponse.getErrors());
if (createResponse.wasSuccessful()) {