Forums

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

R4j API python

PZ March 31, 2024

I have trouble accessing R4j via API using python. I just get bunch of 404 or unauthorized. Can someone give me some guidance or provide me a very basic python file accessing the license status?

I've tried different things; my newest idea below:

token=...
url='http://blabla.atlassian.net/rest/com.easesolutions.jira.plugins.requirements/2.0/license'

auth=HTTPBasicAuth([email], token)

headers = {"Accept": "application/json"}

response= requests.request("GET", url, headers=headers, auth=auth)

...

2 answers

1 accepted

2 votes
Answer accepted
Melo
Community Champion
March 31, 2024

Hi @PZ. Welcome to the community! For the license information retrieval via the R4J REST API, I utilized Python's requests library with JWT authentication. Here’s how the authentication was configured

import requests

jwt_token = 'your_jwt_token'

url = "https://eu.r4j-cloud.easesolutions.com/rest/api/1/license"

headers = {

    "Authorization": f"JWT {jwt_token}",

    "Accept": "application/json"

}

response = requests.get(url, headers=headers)

print(f"Status Code: {response.status_code}")

print("Response Body:", response.json())



I hope it helps.

Cheers,

Melo

PZ April 1, 2024

Awesome, this works. Thanks :)

Now, POST requests like disabling a project do not work. Also, there seems to be a Rest API 2.0 which one should use, do you know how to use it?

It says that one should use the following url structure: <host>:<port>/rest/com.easesolutions.jira.plugins.requirements/2.0/resource

I assume when using a cloud product one doesn't have to specify the port(leave it empty), right?

Edmer John Sarmiento April 1, 2024

Hi @PZ

I'm Edmer from EaseSolutions, vendor of R4J plugin. You can disable an active R4J Project using the REST API: PUT /rest/api/1/projects/{projectId}/disable

Yes, you don't need to include the port, you only need to specify the URI Structure: "https://eu.r4j-cloud.easesolutions.com/rest/api/1/<resource-path>" as what Melo Shared. 

You may find more details about R4J Cloud REST APIs from our Public document.

Best regards,

Edmer

PZ April 1, 2024

This works perfectly. Thanks again.

0 votes
PZ April 1, 2024

[delete answer]

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events