Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hello,
I need to update a jira user object under assets via API call. How do I find the user object id based on username or email via API call?
Any suggestion or idea is highly appreciated.
Thank you
Wendy
@Wendy Wei Below steps should get you accomplish the requirement.
@Gikku thank you for the information. However, I cannot get expected result using below url, it still retrieve 25 users as pageObhectSize, not just the specific one:
https://api.atlassian.com/jsm/assets/workspace/XXXXXXXXX..../v1/aql/objects?qlQuery=objectschemaId=4&objectTypeId=6&username="Wendy.Wei@xxx.com". In addition, i got 405 method not allowed error when using either post or put. but using Get does return results, just not a single result.
Any idea?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Wendy Wei The query should be corrected as 'objectSchemaId' and you can also verify the results by running the same search from the UI to see if you are getting the intended results.
Here is a sample code that I am using with Scriptrunner.
*******
def ASSETS_WITH_TAGS_AQL = 'objectSchemaId=1 AND objectTypeId=2 AND Tag IS NOT EMPTY'
def getDevicesWithUsername = {
post("https://api.atlassian.com/jsm/assets/workspace/${WORKSPACE_ID}/v1/object/aql?maxResults=10&includeAttributes=false")
.basicAuth(ASSETS_ACCOUNT, ASSETS_TOKEN)
.header('Content-Type', 'application/json')
.body([qlQuery: "${ASSETS_WITH_TAGS_AQL}"])
.asObject(Map)
.body
.values as List
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thank you very much for your information. I was able to use below to retrieve the specific object using label, instead of username.
However, I am having issue with create an asset object using below:
https://api.atlassian.com/jsm/assets/workspace/xxxxxx/v1/object/create, i am getting 401 unauthorized error but it wa confirmed the user making the connection does have write permission. I am not sure exact what parameters I should be using. is basic authorization correct? useraccount: password? or username: apitoken when making connection?
thank you very much!
Wendy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Wendy Wei Try using the API token for the script. Basic auth is fine.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.