Hello.
I want to start using JMWE callJira() or callRest(). First case - I want to add another Option for my custom field - Select List (single choice) by API. I've used for that Build-your-own (scripted) Post-function in JMWE and my Nunjucks script is as following:
{{ "/rest/api/2/field/customfield_12800/context/14900/option" | callJira(verb = POST, body={
values:
{
"value": "xxxxxxxxxxxxxxx",
"disabled": false
}
})}}
Id of my customfield is 12800 and I have one context for that field - 14900 id.
I've used and checked GET method for that field to see that ID's are correct and it worked perfectly.
{{ "/rest/api/2/field/customfield_12800/context/14900/option" | callJira(verb = GET) | dump(2)}}
What is wrong with first Nunjucks script? When I'm trying to test that template I receive that (scrrenshot below) but nothing happened, field doesn't have a new option "xxxxxxxxxx".
Have you tried "dumping" the result of the call, to see what that returned object holds?
Also, my guess is that you need to pass an array of value objects, even when adding only one option.
{{ "/rest/api/2/field/customfield_12800/context/14900/option" | callJira(verb = POST, body={
values:[
{
"value": "xxxxxxxxxxxxxxx",
"disabled": false
}
]})}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you @David Fischer for your time and answer :)
I've tried to dump that and I've received the same result as GET method - all options of that custom field.
Thank you for your tip with an array of objects but in that case result is the same.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I checked the REST API doc and the parameter is "options", not "values". Try this:
{{ "/rest/api/2/field/customfield_12800/context/14900/option" | callJira(verb = POST, body={
options:[
{
"value": "xxxxxxxxxxxxxxx",
"disabled": false
}
]})}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You mean the option wasn't added to the custom field's configuration scheme? Did you check the field configuration scheme (context) ID? Also, did you check the returned value (by "dumping" it)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I meant that request doesn't work and option wasn't added.
ID's are proper because when I've changed above method on GET (with dump) I've received all actual options for context - ID 14900 from customfield - ID 12800.
{{ "/rest/api/2/field/customfield_12800/context/14900/option" | callJira(verb = GET)}}
When I use reqeuest as above (without dumping) I receive the same result like in POST method which doesn't work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Again, for debugging purposes, always "dump(2)" the output to see what's inside the returned object.
Can you activate DEBUG-level logging on the JMWE Logs page and try again? This will log the actual call made out to Jira, which will help understand if the call is correct (based on the Jira REST API documentation). If it is correct, then I recommend you try the same call from Postman, to see if it works there. If it doesn't, you might need to ope a support request with Atlassian.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dammit, you found the problem!
You are passing the verb parameter as:
callJira(verb = POST, ...
but that means that the verb will be the value of the POST variable - and since the POST variable is never set, it is empty (undefined). In that case, the default verb is used ("GET").
You need to pass a String as the verb:
callJira(verb = "POST", ...
Unfortunately, I didn't notice it in your previous posts. Sorry about that.
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.