Hi there,
I'm trying to update a custom field "customfield_16220" using python which is failing. It errors 400.
However, the curl works fine.
curl request:
curl --request PUT \
--url 'https://jira.xxxxx.com/rest/api/2/issue/cdc2-96' \
--header 'Authorization: Bearer <token>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"fields": {"customfield_16220":[{"name": "r.a@dddd.com"}]}}
python code:
import requests
import json
cf='customfield_16220'
access_token="<token>"
url = "https://jira.xxxxx.com/rest/api/2/issue/cdc2-96"
payload = {"fields": {"customfield_16220":[{"name": "r.a@dddd.com"}]}}
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer " + access_token
}
response = requests.request('PUT',url, headers=headers, data=payload, verify=False)
print(response)
It returns error code 400. Error:
{"errorMessages": ["Unrecognized token 'fields': was expecting 'null', 'true', 'false' or NaN\n at [Source: org.apache.catalina.connector.CoyoteInputStream@4bc1dc14; line: 1, column: 8]"]}
Here I must tell you that the same python code with the "GET" request (without data) is working fine and that is returning the issue details.
Can you please help me here in updating the customfield?
Try using
response = requests.request('PUT',url, headers=headers, json=payload, verify=False)
The difference is, when using the json argument, you're sending a JSON serializable python object instead.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.