Hello,
I am trying to create a ticket using rest api. One of the fields that I include in payload is customfield
"schema": {"type": "any","custom": "com.riadalabs.jira.plugins.insight:rlabs-customfield-default-object","customId": 19509}
When i check the json of this field in existing ticket it shows me this
"customfield_19509": ["Team123 (PTCI-1549)"]
So my json is
Hi @Kenny Roostam and welcome to the community,
The field you are trying to update is an asset field. As stated by your message, as well as gronthe asset rest api doc, the field should be an array. Please take a look at the documentation:
https://developer.atlassian.com/cloud/assetsapi/rest/api-group-assets/#api-group-assets
In addition, can you please paste here the request you are sending, as well as the payload?
@Kenny Roostam are on jira cloud or on premise?
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.
@Alex Koxaras _Relational_ apologies, i was informed that its cloud but checking now, by going to /rest/api/2/serverInfo "deploymentType": "Server" and version is v9.2
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The check this link https://confluence.atlassian.com/servicemanagementserver/assets-rest-api-documentation-1044101761.html
Find the appropriate asset versions, as well as the right JSM version
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry @Alex Koxaras _Relational_ , so i can't set the values for assets fields using /rest/api/2/issue/ .I should use their own api right?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
From the message you are getting, it seems that it works. However the data you are sending is not an object array.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm sending like this
$payLoad = @{
"fields" = @{
"customfield_19509" = @("Team123 (PTCI-1549)")
}} | ConvertTo-Json
$payLoad = @{
"fields" = @{
"customfield_19509" = @(@{"value" = "Team123 (PTCI-1549)"})
}} | ConvertTo-Json
it creates the ticket however this field is not visible in ticket in browser. When i get the json of this ticket I see that its null "customfield_19509": null
However in another existing ticket json looks like this
"customfield_19509": ["Team123 (PTCI-1549)"]
This ticket was created using UI
Do you know maybe how should I send this array properly?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have tried with postman as well. When I send "customfield_19509": ["Team123 (PTCI-1549)"]
I get
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @Alex Koxaras _Relational_ thanks for quick response
$token = ""
$headers = @{
Authorization = "Bearer $token"
"Content-Type" = "application/json"
}
$payLoad = @{
"fields" = @{
"project" = @{
"key" = "SDSD"
}
"issuetype" = @{
"name" = "Change Request"
}
"summary" = "Test change request"
"description" = "test change request"
"assignee" = @{
"name" = "john.doe"
}
"customfield_13804" = @{
"value" = "Standard"
}
"customfield_19509" = @("Team123 (PTCI-1549)")
}
} | ConvertTo-Json -Depth 10
Invoke-RestMethod -Uri https://jirainstanceXXX.com/rest/api/2/issue/ -Method 'Post' -Headers $headers -Body $payLoad -ErrorAction Stop
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.