Hello,
I am trying to set the assignee of the user as per the command:
PUT: https://localhost:8080/rest/api/2/issue/issue-key/assignee
Content-Type: application/json
Auth: Basic Auth
I am getting the following error:
{ "errorMessages": [], "errors": { "assignee": "User 'sdxwwr' does not exist." }}
Could someone help me with the code to catch this exception
Note: The field where the user enters his name is a text field
Your rest call should look like this,
curl -D- -u username:password -X PUT -H "Content-Type: application/json" https://<JIRA_BASE_URL>/rest/api/2/issue/<ISSUE_KEY>/assignee -d "{\"name\":\"<ASSIGNEE_NAME>\"}"
Once you hit this API get response and parse it as JSON and it contains key 'errorMessages' or 'errors', it implies you had some error setting assignee. In your case above 'sdxwwr' is not user in your Jira.
If you want to know how to do it in any programming language let me know.
I cannot provide you with C# sample as I am on Mac but here is Node.JS sample that can help you.
// This code sample uses the 'request' library: // https://www.npmjs.com/package/request var request = require('request'); var bodyData = `{ "name": "<ASSIGNEE_NAME>" }`;
var JIRA_BASE_URL = "<YOUR_BASE_URL>";
var ISSUE_KEY = "<ISSUE_KEY_OR_ID>"; var options = { method: 'PUT', url: `${JIRA_BASE_URL}/rest/api/2/issue/${ISSUE_KEY}/assignee`, headers: { 'Authorization': "BASE64_ENCODED<USERNAME>:<PASSWORD>", 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: bodyData }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log( 'Response: ' + response.statusCode + ' ' + response.statusMessage ); console.log(body); });
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.