I am using this code:
payload = {'update': { 'summary': [ {'set': 'new summary here'} ] } }
url = 'https://my-jira-server/resr/api/2/issue/CCB-666'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
}
requests.put(url, headers=headers, data=payload)
The call fails with error 400 with this message:
"Unexpected character ('u' (code 117)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')"
I've verified that the 'u' it refers to is the start of the 'update' in the payload.
What am I doing wrong here?
Found the solution!
After re-reading requests() documentation here: https://requests.kennethreitz.org/en/master/user/quickstart/, in the section titled 'More complicated POST requests',
I changed the code to this:
requests.put(url=url, headers=headers, json=payload)
and it worked.
Hi Amir,
Does quoting the whole payload/data object help?
E.g.
payload = {'update': { 'summary': [ {'set': 'new summary here'} ] } }
Becomes
payload = '{"update": { "summary": [ {"set": "new summary here"} ] } }'
I don't really give this a lot of hope but other than that the request looks fine to me so.. My $0.02
//Radek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello @Amir Katz (Outseer) ,
the u before a string in python stands for Unicode.
You should check on why your python code is considering the payload as Unicode and not utf-8
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No it's not. When I changed the key 'update' to 'Xupdate' I got the error on the character 'X'.
So the API is expecting a different JSON structure, but it's unclear what exactly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Amir Katz (Outseer) my mistake, I read the quesiton quickly.
have you tried double quotes instead of the single quote?
the JSON format seems correct.
if you still can't find your solution, I usually use the jira-python module.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Than ks. But this code is in Python, so single- and double-quotes are the same - a string.
Regarding the jira-python module, I'm aware of it, but it is quite complicated to use. I used it in the past on Linux.
I did try to install it, and it failed when it was trying to compile some SSL-related code.
This is on Windows 10...
I guess the latter problem is for another thread.
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.