Trying to create a user in Jira DataCentre 8.20 using the API rest/api/2/user listed as "experimental" using Python Requests
I'm sending a POST with the header 'Content-Type': 'application/json;charset=UTF-8'
data as follows (redacted):
{"name": "username","emailAddress": "forename.surname@domain.co.uk","displayName": "Forename Surname","applicationKeys": ["jira-software-users"]}
And it gives me back the error:
Can not instantiate value of type [simple type, class com.atlassian.jira.rest.v2.issue.UserWriteBean] from JSON String; no single-String constructor/factory method
Have I made a mistake with the JSON string, or some other error?
I'm assuming applicationKeys corresponds to the Jira user group to add the user to.
Thanks
Brian
Aha! I found the answer. I guess the clue was the "single string" part of the error.
I was using Python Requests, and in the call:
session.post(hostURL, json=my_data)
I was already passing json data as my_data. So it was encoding it twice.
I changed it to
session.headers['Content-Type'] = 'application/json'
session.post(hostURL, data=my_data)
It now works!
It didn't add the user to the group "jira-software-users" so I guess the applicationKeys parameter is for something else. I guess I can just add the user to the group in a later call to update the user.
I hope that helps others who come across this. :-)
I found if I omit the applicationKeys section, the user is created in the correct group anyway.
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.
Hi @Brian Craigie I faced the exact same issue. This solution of passing data=my_data really helped me. It solved my problem. Many many thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Welcome to the community!
Can you update the JSON data like below and try? I have enclosed everything within 'fields' section:
{
"fields": {
"name": "username",
"emailAddress": "forename.surname@domain.co.uk",
"displayName": "Forename Surname",
"applicationKeys": ["jira-software-users"]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Vamsi Kandala Thank you for your kind welcome and your reply. However, that gives me the same error message.
I was using the example in the API documentation, albeit the documentation is for 9.5, not 8.20.
The example shows:
{
"name": "charlie",
"password": "abracadabra",
"emailAddress": "charlie@atlassian.com",
"displayName": "Charlie of Atlassian",
"applicationKeys": [ "jira-core" ]
}
I am omitting the password as the documentation says "If password field is not set then password will be randomly generated."
I tried adding the password, but still get the same error.
I've also confirmed I get the same error using Jira DataCentre 9.4
Thanks again.
Brian
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.