Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,361,708
Community Members
 
Community Events
168
Community Groups

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

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

2 votes
Answer accepted

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.

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.

I tried with that 

"customfield_10302": [

{

"id": "{workspaceid}:19403"

}

]



and get 

{

"errorMessages": [],

"errors": {

"customfield_10302": "Validation failed for Insight object"

}

}

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
Community showcase
Published in Jira Service Management

An unofficial way to monitor a JSM mail handler for errors

...eturns true if any content is returned for the webResponse.body.data.first s...

718 views 3 20
Read article

Atlassian Community Events