Update License via REST returns code 415

Martin Baltuhin June 7, 2021

I have several host licenses to update and i want to automate it. Getting license works without issues. Setting license does not work, returns response code 415 without any text.

Using python3.

Headers:

headers = {"Content-Type": "application/json", "Accept": "*", "Authorization": "Basic "+encoded} 

and the test get request:

response = requests.get(jira_base+"/rest/plugins/applications/1.0/installed/jira-software/license", headers=headers)

this works. 
Setting the license does not. Using same headers and this is my request.

data = {
"licenseKey": "<MyLicenseKey>"
}
headers = {"Content-Type": "application/json", "Authorization": "Basic "+encoded}
response = requests.post(jira_base+"/rest/plugins/applications/1.0/installed/jira-software/license", headers=headers, data=json.dumps(data))

 following this page: https://confluence.atlassian.com/jirakb/how-to-retrieve-application-license-details-or-set-the-license-via-private-rest-api-in-jira-7+-934728265.html

and i get <Response [415]> without any other info.

1 answer

0 votes
Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 7, 2022

I use the next method

def update_plugin_license(self, plugin_key, raw_license):
"""
Update license for plugin
:param plugin_key:
:param raw_license:
:return:
"""
app_headers = {
"X-Atlassian-Token": "no-check",
"Content-Type": "application/vnd.atl.plugins+json",
}
url = "rest/plugins/1.0/{plugin_key}/license".format(plugin_key=plugin_key)
data = {"rawLicense": raw_license}
return self.put(url, data=data, headers=app_headers)
Martin Baltuhin February 8, 2022

Wow, thank you! Does this work for Jira license itself?

Like Gonchik Tsymzhitov likes this
Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 8, 2022

For the Jira License, I did not test yet

https://github.com/atlassian-api/atlassian-python-api/blob/master/atlassian/jira.py#L2825

 

once it's ready I will share info

Martin Baltuhin February 22, 2022

I am still getting 405:

HTTPError: 405 Client Error: for url: http://jira:8080/plug
ins/1.0/org.everit.jira.timetracker.plugin/license

i am using this:

response = jira.update_plugin_license(plugin['key'], raw_license) 

is there any specific way you have to format the license itself? Does this work with later versions?

Suggest an answer

Log in or Sign up to answer