Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

creating Relationship Between any of two ci class through IRE API

SLeelaRaR
Tera Contributor

How can i create relationship between any two ci class with the help of Identification and Reconciliation API

1 ACCEPTED SOLUTION

Maniteja_2003
Tera Guru

Hello @SLeelaRaR,

To create relationships between any two CI classes using the IRE API, you can follow this approach:

First, build a JSON payload containing the two CI classes along with the relationship you want to establish between them. Then, call the IRE API with this payload.

 

 

var payload = {
"items": [
 
{
"className": "cmdb_ci_computer",
"values": {
"serial_number": "test12356",
"name": "Server0012",
"ip_address": "10.10.10.20"
}
},
{
"className": "cmdb_ci_appl",
"values": {
"name": "Payroll-App",
"version": "1",
"tcp_port":"443"
}
}
],
"relations": [
{
"parent": 1,
"child": 0,
"type": "Runs on::Runs"
}
]
};

var input = new JSON().encode(payload);

var output = SNC.IdentificationEngineScriptableApi.createOrUpdateCIEnhanced(
'ServiceNow',
input,
{}
);
gs.print(output);
 

Screenshot 2026-02-23 at 1.05.09 PM.pngScreenshot 2026-02-23 at 1.05.14 PM.pngScreenshot 2026-02-23 at 1.05.27 PM.png

Please mark it as helpful.

Regards,
Maniteja.

View solution in original post

3 REPLIES 3

Maniteja_2003
Tera Guru

Hello @SLeelaRaR,

To create relationships between any two CI classes using the IRE API, you can follow this approach:

First, build a JSON payload containing the two CI classes along with the relationship you want to establish between them. Then, call the IRE API with this payload.

 

 

var payload = {
"items": [
 
{
"className": "cmdb_ci_computer",
"values": {
"serial_number": "test12356",
"name": "Server0012",
"ip_address": "10.10.10.20"
}
},
{
"className": "cmdb_ci_appl",
"values": {
"name": "Payroll-App",
"version": "1",
"tcp_port":"443"
}
}
],
"relations": [
{
"parent": 1,
"child": 0,
"type": "Runs on::Runs"
}
]
};

var input = new JSON().encode(payload);

var output = SNC.IdentificationEngineScriptableApi.createOrUpdateCIEnhanced(
'ServiceNow',
input,
{}
);
gs.print(output);
 

Screenshot 2026-02-23 at 1.05.09 PM.pngScreenshot 2026-02-23 at 1.05.14 PM.pngScreenshot 2026-02-23 at 1.05.27 PM.png

Please mark it as helpful.

Regards,
Maniteja.

Hi @Maniteja_2003  , Thanks for the reply,  I have one doubt i want to write payload like this(as you wrote) in IRE API Request body in REST API EXPLORER -->identifyandreconcileapi .
i created relationship with that API but  i didn't write the  (

var input = new JSON().encode(payload);

 

var output = SNC.IdentificationEngineScriptableApi.createOrUpdateCIEnhanced(
'ServiceNow',
input,
{})
did you write this in background script ?....

 



Hello @SLeelaRaR,

Yes — I executed the script using Background Scripts.

In REST API Explorer, the Request Body is only used to provide the JSON payload required to create or update data in the table. JavaScript code cannot be executed there.

Regards,
Maniteja