The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Creating an issue with default assignee currentUser()

Andreas Wohlmuth
December 29, 2023

Hello,

how to assign my user as assignee with a function?

'{ "fields": { "project": { "key": "AUTOMAT" }, "summary": "REST ye merry gentlemen.", "assignee":{"name":currentUser()} , "description": "Creating of an issue using project keys and issue type names using the REST API", "issuetype": { "name": "Aufgabe" } } } '

 

error:

400 : {"errorMessages":["Unexpected character ('c' (code 99)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.apache.catalina.connector.CoyoteInputStream@b4699d9; line: 1, column: 111]"]}

 

thanks

Andreas

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Evgenii
Community Champion
December 30, 2023

Hi, @Andreas Wohlmuth 
If I understood right, you're using REST API to set assignee.

You need to use username, as value for "name". But you're trying to use currentUser() which is internal function of Jira, and returns user as whole object. 

I'd check currentUser().username but I'm not sure that it'll work. It needs to be tested

0 votes
Tansu Akdeniz
Community Champion
December 30, 2023

Hi @Andreas Wohlmuth 

From where do you trigger this web request? Groovy script? Automation?

Ex script to get currentUser:

import com.atlassian.jira.component.ComponentAccessor
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

After getting the user object, you can provide required attribute as a parameter (considering escape characters) to JSON.

Andreas Wohlmuth
December 30, 2023

Hi Evgeniy,

thanks for hint currentUser().username

 

Hi, Tansu,

I am using Delphi to connect and will check Delphi lib for similar getJiraAuthenticationContext

 

client_post := TRESTClient.Create(nil);

....

body_s:= text.Text.Replace(''#$D#$A'','\n') ;

request_post.Method := TRESTRequestMethod.rmPost;
request_post.Resource := '/rest/api/2/issue';
request_post.AddBody(body_s, ctAPPLICATION_JSON);

request_post.Execute;

 

many thanks for help

Andreas

Like Evgenii likes this