Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unirest is not working , Is there any other way to connect?

Manjeet_Chaudhary
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 1, 2020

HttpResponse<JsonNode> response = Unirest.get("/rest/api/3/applicationrole")
                  .basicAuth("email@example.com", "<api_token>")
                  .header("Accept", "application/json")
                  .asJson();                   System.out.println(response.getBody());

 

<!-- https://mvnrepository.com/artifact/com.mashape.unirest/unirest-java -->
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>

1 answer

0 votes
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 3, 2020

Hello @Manjeet_Chaudhary ,

Welcome to the Atlassian Community!

If I understand correctly you are trying to use Unirest-Java (http://kong.github.io/unirest-java/) to send REST API requests to Jira Core Cloud, but something is not working. Is this correct? 

If this is correct, could you let us know what is not working exactly?

I am asking this since, looking at the provided code, it seems you are just using the sample data from the REST API documentation for /rest/api/3/applicationrole endpoint:

HttpResponse<JsonNode> response = Unirest.get("/rest/api/3/applicationrole")
                  .basicAuth("email@example.com", "<api_token>")

 

However, please notice that is just an example and therefore in your code you should replace the sample values with the real one.

Specifically:

  1. You have to provide the full url for your instance together with the REST API endpoint (replace <YOUR_SITE_NAME> with your Jira site name)
    HttpResponse<JsonNode> response = Unirest.get("https://<YOUR_SITE_NAME>.atlassian.net/rest/api/3/applicationrole")
  2. You have to use email address and Api Token of an existing user (with proper rights) in your instance:
    .basicAuth("maxxxxxxxxx88@gmail.com", "loxxxxxxxxxxxxxxxxxxD5")

 

For details on how to generate an Api Token for your user, please see:

 

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events