Hello,
I'm trying to create a release version in JIRA via a REST API call.
I have access to do this manually from the UI.
I can also fetch the current release versions, so my session cookies should be OK.
Getting a 404 saying "errorMessages":["Project with key \\'XXX\\' either does not exist or you do not have permission to create versions in it." when try to do the POST.
Code below:-
import requests
import json
import getpass
user_name = input("Please enter your user name (Provide with quotes. Ex :- 'john.smith'):- ")
password = input("Please enter your password (Provide with quotes. Ex :- 'abc123'):- ")
response_init = requests.post("https://jira.xxx.com/rest/auth/1/session",
data='{ "username": "' + user_name + '", "password": "' + password + '" }',
headers={"Content-Type": "application/json"})
cookie_name = response_init.cookies._cookies['jira.xxx.com']['/']['JSESSIONID'].name
cookie_value = response_init.cookies._cookies['jira.xxx.com']['/']['JSESSIONID'].value
cookie = cookie_name + "=" + cookie_value
# I can fetch the current versions for the project. So I guess my access cookie is working.
response_get = requests.get("https://jira.xxx.com/rest/api/2/project/PNG/versions", headers={"Cookie": cookie})
print(response_get.text)
body = json.dumps({
"self": "http://jira.iress.com/rest/api/~ver~/version/33072",
"description": "Created @ CodeIT",
"name": "2019-Jul-WK28",
"archived": "false",
"released": "false",
"releaseDate": "2019-07-12",
"project": "XXX",
#"projectId": 33072,
"id": "33072",
"overdue": "false"
}
)
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"Bearer": cookie
}
# This is the request which is failing.
response_post = requests.request("POST", "https://jira.xxx.com/rest/api/2/version", data = body, headers = headers)
print response_post.status_code
if response_post.status_code == 200:
print "you did it!!"
Are you sure your auth headers are right? I think you need something like:
"Authorization: Bearer " + cookie_value
HTH.
Viraj, hi!
Make sure that user, which creates version has all permissions for this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well as I mentioned this user can create it manually via the Web UI. It's only the REST call which is not working.
I saw this :-
https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-api-3-version-post
Anyone know what OAuth scopes means in there??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.