Forums

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

How to assign a Insight object to a custom field using Rest API?

Andre Lara Oliveira e Silva
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 19, 2022

Hey there, 

I just have an issue type that goes with an Insight object under a customfield.

However, i can not manage to create this issues neither using Jira for Python lib or Jira REST API directly.

I went over these two topics below, and none of the solutions worked for me

https://community.atlassian.com/t5/Jira-Service-Management/JSON-body-example-that-links-an-Insight-object-to-a-JSM-issue/qaq-p/1986713

https://community.atlassian.com/t5/Jira-Service-Management/Jira-API-Insight-object-customfield/qaq-p/1276723

 

for the payload as 

{

"fields": {

"project":{"key":"DEMO1"},

"summary": "Create JIssue test",

"description": "Create Jissue test",

"issuetype": {

"id": "10213"

},

"customfield_10424" : [{

"workspaceId":{workspace_id},

"id":"446",

"objectId": "446"

}]

}

}

i just got a server error

{"errorMessages":["Internal server error"],"errors":{}}

if i replace the insight object formatting, and pass only the key, the ticket is created, but with the customfield as empty.

{

"fields": {

"project":{"key":"DEMO1"},

"summary": "Create JIssue test",

"description": "Create Jissue test",

"issuetype": {

"id": "10213"

},

"customfield_10424" : [{

"key":"CUS-445"

}]

}

}

 

This is how a manually issue, with Insight object properly set, looks like for the customfield

 

jira.png 

if i just try to update that issue by code, using:

issue.update(fields={'customfield_10424':[{

"key":"CUS-175"

}]})

 the customfield_10424 will go empty. 

empty.png

I would be pleased if someone could help me figure this out, or maybe explore other alternatives, Thanks!

1 answer

1 accepted

5 votes
Answer accepted
Andre Lara Oliveira e Silva
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 22, 2022

After going deeper on that, just found out the syntax that worked for me.

customfield_10424=[{

"id":"{workspaceId}:445",

}]

idk why this is not well document over jira docs, since there are similar scenarios and different syntaxes.

Ant'One Delorme August 26, 2022

Hi Andre, I just have a question, what is "workspaceid" is it the name of your object ?

Can you confirm as I'm switching form server version to Cloud and the call api is not possible with the old method with the key.

 

Thanks.

Ant'One Delorme August 26, 2022

I tried with that 

"customfield_10302": [

{

"id": "{workspaceid}:19403"

}

]



and get 

{

"errorMessages": [],

"errors": {

"customfield_10302": "Validation failed for Insight object"

}

}
Ant'One Delorme August 31, 2022

I just the solution on how to find the workspaceid, for those looking here and that don't know just make a call to :

 'https://{yourcompany}.atlassian.net/rest/servicedeskapi/insight/workspace' 

Like Matteo Vecchiato likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events