It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to access JIRA API with the R package httr?

I am trying to access a JIRA API with the R package httr, but I am having authentication issues and I can not access.

I could access the JIRA API with Postman. The latest official Postman release did not work (because of proxy configuration settings), but I could access the JIRA API with the beta version Postman Canary.

I have previously posted this issue in the httr github:

And I have also posted this issue to the R Studio community:


I think it is also a good idea to post this issue in the JIRA community, as someone may have experience with both JIRA APIs and the R package httr. I am copying below the same text I used in the previous postings.


I am trying to access a JIRA API with httr in R and I am having authentication issues.
I am also using proxy at work, but I found this link (#417) very useful (thank you!), because I could solve the proxy authentication error (407),.. but now I have error 401.

I am using the following code:



credentials <- base64_enc(credentials)
header_auth <- paste0("Basic ",credentials)

add_headers(Authorization = header_auth),
set_cookies(atlassian.xsrf.token = "long_cookie_1",
JSESSIONID = "long_cookie_2"),
authenticate(user = "myusername",password = "mypassword",type="basic"),use_proxy("",8080,username="myusername",password="mypassword", auth="basic"),verbose(),accept_json())

But after that I am getting error 401. I have tried without adding add_headers and set_cookies, but it still gives the same error.

I have tried to modify the use_proxy username and password and gives proxy authentication error (407) when I am using the wrong username and password (401 if they are correct).

But if I modify the username and password in the authenticate section, when I use wrong password and username it still gives error 401 (if the use_proxy section is using the correct username and password). When I use the correct password and username in authenticate also gives error 401.

In the first lines of the verbose output, it says 200 connection established, but in the following lines it appears status 401.

I could access to the JIRA API successfully using Postman (not the latest official Postman release, but a beta version, Postman Canary, which allowed to configure proxy with authentication). To access with Postman I had to first send a POST to url_jira_ini (the authentication site), and after that it generates 2 cookies (atlassian.xsrf.token and JSESSIONID), then I could send a GET to url_jira (the JIRA API that I want to access), which is using basic authentication and the cookie JSESSIONID to access the JIRA API.

In Postman, I have to add the following line in the body (raw):

{"username": "myusername" , "password" : "mypassword" }

Would it be possible to add a body in httr, keeping exactly the same line above used in Postman?
I tried to create a body (list) with that line, but it gives error. Any suggestions?

In case it may be useful, to access the JIRA API in Postman Canary (after configuring the proxy for authentication), I followed the next steps:

  • Delete all cookies previously generated by JIRA.
  • In the Authorization section, add Authorization "BasicAuth", and include username and password.
  • In the Body section, select "Raw" and "JSON (application/json)". And in the Body add the following text:
    {"username": "myusername" , "password" : "mypassword" }
  • Send a POST to the JIRA API authentication (url_jira_ini)
  • Check if it gives 200, and that it gives a JSESSIONID in the cookies (token needed to access the JIRA API).
  • Send a GET to the JIRA API (url_jira)

What should I do to access the JIRA API with httr?
Should I add additional headers in httr?

Please let me know if you need more information.
I need to solve this issue as soon as possible.
Thank you.






1 answer

I'm having the same issue.  I've used a similar connection setup in the past, but all of a sudden it does not work.

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you