Jira Cloud Asset/Insight Set Default Value

Hello all,

I am currently implementing a synchronisation between two Jira Cloud instances. Overall it is working with general/default information and components. The goal is to set specific Jira Assets/Insights as default for values (where we know the asset id) in the ticket itself in the Exalate Incoming Script.

We are working with different kinds of Assets/Insights objects. For instance Customer which is defined as an Asset object in Jira with different attributes (ids, …) and values. Normally you can select wich Asset object you would like in the Customer field in the ticket.

I have already checked other forum entries and this documentation: How to Sync Insight Custom Fields but they are either not fully answered/working and the documentation (if I understood it correctly) only assigns the replica Insight field as a string to the issue which doesn’t work in my case because I have to assign the object itself.

I already tried fetching via REST API the Jira Asset object via ID which worked but when I try to assign it to the Insight/Asset custom field object (not a string) of the ticket it is never assigned and stays empty.

Does someone have a solution for this case?

Any help is appreciated!

Thanks!

Best Regards,
ExalateUser321

Hi @ExalateUser321 ,

Thanks for creating this community post.

Let me pitch in here to help you a bit.

May I please ask you to first try to set the value of the Asset field via POSTMAN?

Once we are able to do this via a PUT/POST request, we can then use the same API call from withing exalate using GroovyHttpClient.

Sharing an example below for your reference.

String key = issue.key
def result = httpClient.get("/rest/api/latest/issue/"+"$key")
def workspaceId = ("${result.fields."customfield_10062".workspaceId}".replace("[","").replace("]",""))
def objectId = ("${result.fields."customfield_10062".objectId}".replace("[","").replace("]",""))
def USER = "dhiren.notani@exalate.com"
def PASS = "xyz"
//getting the Asset field details using the above fetched workspace and objectid using groovy http client
def res = new GroovyHttpClient(nodeHelper)
.http(
    "GET",
    "https://api.atlassian.com/jsm/assets/workspace/${workspaceId}/v1/object/${objectId}",
    null,
    [
    "Content-type" : ["application/json"],
    "Authorization" : ["Basic ${(USER+":"+PASS).bytes.encodeBase64().toString()}".toString()]
    ]
)

Hope this helps!

Thanks, Dhiren

2 Likes