Hi, I have a custom customfield that is an array:
MultipleField extends AbstractCustomFieldType<Collection<String>, String>
I have to insert data with this field via REST api, and when I send this json:
{"fields": {"summary": "asdf","issuetype": { "id": "10014" }, "project": { "id": "10000" }, "customfield_10400": ["asdf","asdfdaogaeogeryghoe"] } }
it says to me that it expects an string as a value of the custom field...
{"errorMessages":[],"errors":{"customfield_10400":"Operation value must be a string"}}
How I can set a list of Strings as the value of the custom field via rest api? It is not possible to log and fill it via UI.
Thanks!
Community moderators have prevented the ability to post new answers.
I had some issues with a string custom field when using the Rest API to create a ticket.. getting the same operation value must be a string error. I played with formatting the request Json. In my case, it was a string field that JIRA converts to a hyperlink automatically.
Simply pop the following into the Json body for issue post:
"customfield_14401": "some string that you want to update on your ticket"
On ticket update, this will work:
{"update":{
"customfield_14401":[{"set":"some string that you want to update on your ticket"}]
}
}
If I want to set customfield_14401 to ["string1", "string2"], what is the Json body like please?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I managed to insert only 1 string by the following,
"customfield_18240": "{\"name\":\"aaaaaaaaaaaaaaaa\", \"name\":\"test case bbbbbbbbbb\"}"
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.
At last I found how to pass more than one value for multiselect custom field,
"customfield_18240": "{\"name\":\"aaaaaaaaaaaaaaaa\", \"name\":\"test case bbbbbbbbbb\"}#|#{\"name\":\"bbbbbbbbb\", \"name\":\"test case cccccccccc\"}"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I finally passed a json object as an string and parsed inside jira.
Thank you 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.
From what I see, you send a JSON array to the API, which requires a string. Have you tried JSON.stringify(["asdf","asdfd..oe]) to turn your array in a valid string?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is not the problem, the json is valid, it's an array and it follows JSON standards, I want to know why it isn't accepted by jira...
The main problem is that it says that customfields only accept Strings, then why labels customfield accepts so?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did not mean to say your JSON would be invalid, but Jira is sometimes quite tricky in its demanded types. So I suggested you transform your JSON into a string by using JSON.stringify. This should provide you with a string for the API, which will turn this string back to a JSON object. Don't ask me why one would have to do this unnecessary step, but in some cases Jira wants exactly these kind of strings to be send. Just give it a try, it might just work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm using the rest api browser plugin. No need to stringify.see:
I need to know the correct format to upload array values and be parsed so. I asume there is an special tratment for that different from JSON standards, that's what I'm asking here.
OR
Maybe my custom field module configuration is not correct and I need to set something especial in order to accept arrays:
{ "id": "customfield_11000", "name": "testField", "custom": true, "orderable": true, "navigable": true, "searchable": true, "clauseNames": [ "cf[11000]", "testField" ], "schema": { "type": "array", "items": "string", "custom": "org.test.rest-plugin:multiple-field", "customId": 11000 } },
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As far as I know (and I tested your format with an array of string field on our system) your syntax is correct and should work just fine. However, it seems Jira had some issues with setting array fields and the only way to work around it was to only send a single value at a time. So instead of placing the whole array when you create the issue via rest, you only could place a single value and set the rest later.
An other recomendation from me so see if it would work at all would be to add your customfield to the default screen of your jira, so you can edit it in the create dialog. This way you could add multiple values and then look at the actual request send by jira to it's rest api by using firebug or something similar. By doing so you should get a valid request body, which you could later implement for your own purpose.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.