Forums

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

Getting error while creating an issue using jira rest api and python

Rahul Singh April 22, 2018
a=(issues["fields"]["assignee"]["name"])
#print (a)
tricat = (issues["fields"]["customfield_14307"])
#print(tricat)
url = "http://ontrack-internal.mycpmpany.com/rest/api/latest/issue"
payload = "{\r\n\t\"fields\":{\r\n\"project\":{\"key\":\"SSET\"},\r\n\"summary\":" + s + ",\r\n\"description\":" + (k + s) + ",\r\n\"issuetype\":{\"name\":\"Task\"},\r\n\"customfield_12610\":{\"value\":\"High\"},\r\n\"components\":[{\"name\":\"Other\"}],\r\n\"assignee\":{\"name\":"+ a +"}\r\n}}"

headers = {
'authorization': "Basic dGFjY3VzZXI6QUg2NF91aDE=",
'content-type': "application/json",
'cache-control': "no-cache",
'postman-token': "07236ec6-85de-3202-49ce-cfc4e78a0eac"
}

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)



Getting error
{"errorMessages":["Unexpected character ('H' (code 72)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.apache.catalina.connector.CoyoteInputStream@4b650670; line: 4, column: 13]"]}
{
{"errorMessages":["Unexpected character ('U' (code 85)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.apache.catalina.connector.CoyoteInputStream@4b650670; line: 4, column: 13]"]}

Please help me to resolve it

1 answer

1 vote
Shaun S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 23, 2018

Hi Rahul,

 

My first thought is the method the request is being called with.  If you use :

response = requests.post(url, data=payload, headers=headers)

 Does it still return an error?  Additionally you may need to dump the payload to json first before the request is sent.

import json

...

json_data = json.dumps(payload)

response = requests.post(url, data=json_data, headers=headers)

 Hope that helps!

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events