I'm looking for a way to submit a portal form using Python. For example I have a form at https://instance.atlassian.net/servicedesk/customer/portal/1/group/1/create/1
I can authenticate using email:token with or without the jira module and also create issues. However I want to create issues by submitting the form on the portal. Is there a way to do this using python? Can be with or without using the jira module
For reference here is the code I have to authenticate and create issues using the jira module:
from jira import JIRA
jira_connection = JIRA(basic_auth=('[email protected]', 'tokenxxxxxxxxx'), server="https://myinstance.atlassian.net")
issue_dict = {
'project': {'key': 'TEST'},
'summary': 'Testing script',
'description': 'Testing script',
'issuetype': {'name': 'Service Request'},
}
new_issue = jira_connection.create_issue(fields=issue_dict)
print(new_issue)
And here is the code without using the jira module:
import requests
import json
url = "https://myinstance.atlassian.net/rest/api/3/myself"
headers = {
"Authorization": "Basic <base64 encoded email:token>",
"Accept": "application/json"
}
response = requests.request( "GET", url, headers=headers )
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
This is the POST I'm trying but getting a 400:
jira_load={
"fields": {
"description": {"version":1,"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Test description"}]}]},
"summary": "Test summary",
"project": {
"key": "TEST"
},
"issuetype": {
"name": "IT Help"
},
}
}
url = 'https://instance.atlassian.net/servicedesk/customer/portal/1/create/1'
r = requests.post(url, data=jira_load)
print ("HERE's the JSON RESPONSE\n\n ", r.status_code, r.headers)
print ("The response content is\n\n", r.content)
For Jira Service Management, you can use its REST API: https://developer.atlassian.com/cloud/jira/service-desk/rest/intro/#jira-cloud-platform-apis to operate on Portal issues (Create - https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-post). I suppose that this JIRA library is open source and maybe does not have SD operations (not sure what lib it is).