Using the REST API to input a custom asset field in JSM

Insight’s object schema is now linked with JSM’s custom fields.
Integrating Insight with Jira

I will be using the REST API to input this custom field.

I have confirmed that the custom field can be populated in the format “${appKey}/${originId}”.
Is it possible to specify the name of the Insight object as the value without using
“${appKey}/${originId}”?

{
    "update" : {
        "customfield_12345" : [{"set": [{"value" : "com.riadalabs.jira.plugins.insight/1234_12"}]}]
    }
}

Welcome to the Atlassian developer community.

You should be able to use the REST API without using the “${appKey}/${originId}”.

In case you didn’t manage to use the raw data instead of the variables, please share the error message.

@CassioPilla
For example, set the field to an object which object’s name is HostA.
The following has been specified for BODY.

{
    "update" : {
        "customfield_12345" : [{"set": [{"value" : "HostA"}]}]
    }
}

The errors are as follows.Am I doing something wrong?

“Field ‘customfield_12345’ cannot be set. It is not on the appropriate screen, or unknown.”

@MasayukiAbe,

Is it possible to specify the name of the Insight object as the value without using
“${appKey}/${originId}”?

No. Since there could be duplicate assets with the same name, you must use appKey and originId. Fortunately, it is pretty simple to look these up with GET /rest/assetapi/asset/search in the Search assets endpoint. The JSON results already have the 2 parts you need in the origin object:

{
  "values": [
    {
      "origin": {
        "appKey": "com.myasset.app",
        "originId": "5-113-51143-2032"
      },
...
}

@ibuchanan
Using the URI in Jira Cloud I was able to extract the object.
Thanks for the very useful information!

1 Like