How can we help?
{{docApp.searchError}}
{{product.name}}
Searching in {{docApp.searchFilterBySpecificBookTitle}}
{{docApp.searchResultFilteredItems.length}} results for: {{docApp.currentResultsSearchText}}
in {{docApp.searchFilterBySpecificBookTitle}}
Search results have been limited. There are a total of {{docApp.searchResponse.totalResultsAvailable}} matches.
You have an odd number of " characters in your search terms - each one needs closing with a matching " character!
-
{{resultItem.title}}
{{resultItem.url}}
{{docApp.libraryHomeViewProduct.title || docApp.libraryHomeViewProduct.id}}
{{docApp.libraryHomeViewProduct.description}}
{{group.title || group.id}}
{{group.description}}
Operation Information
- Application Reference:
com.hornbill.servicemanager
- Scope:
Entity - Asset
- Class:
Entity
- Required Privilege Level:
none
- Required Rights: none
Description
This flowcode operation links an asset to another asset, request or other system entity.
Request Parameters
The linkAsset API takes the following input parameters.
Note
When sending a JSON request payload to the API, the order of parameters is not significant. However, for XML request payloads, parameters must be provided in the exact order specified in this documentation to comply with input validation requirements.
Name | Type | Required | Description |
---|---|---|---|
leftEntityId |
xs:string |
Yes | The id of the first entity to be linked. |
leftEntityType |
xs:string |
Yes | The entity type of the first entity to be linked. (Asset, Request etc) |
leftRelType |
xs:string |
No | The relationship type of the first entity to be linked. (Connected to, Installed On etc) |
rightEntityId |
xs:string |
Yes | The id of the second entity to be linked. |
rightEntityType |
xs:string |
Yes | The entity type of the second entity to be linked. (Asset, Request etc) |
rightRelType |
xs:string |
No | The relationship type of the second entity to be linked. (Connected to, Installed On etc) |
dependsOn |
xs:string |
No | The link dependency, if any. |
Response Parameters
Name | Type | Description |
---|---|---|
recordsLinked |
xs:boolean |
true if records linked successfully, otherwise false |
exceptionName |
xs:string |
The name / code of any exception thrown during the linking of the asset. |
exceptionSummary |
xs:string |
A description of any exception thrown during the linking of the asset. |
Code Examples
curl -X POST 'https://api.hornbill.com/yourinstanceid/xmlmc/apps/com.hornbill.servicemanager/Asset' \
-H 'Authorization: ESP-APIKEY yourHornbillAPIKey' \
-H 'Content-Type: application/json' \
-d '{"@service":"apps/com.hornbill.servicemanager/Asset","@method":"linkAsset","params":{"leftEntityId":"xs:string","leftEntityType":"xs:string","leftRelType":"xs:string","rightEntityId":"xs:string","rightEntityType":"xs:string","rightRelType":"xs:string","dependsOn":"xs:string"}}'
package main
import (
"fmt"
apiLib "github.com/hornbill/goApiLib"
)
func main() {
hornbillAPI := apiLib.NewXmlmcInstance("yourinstanceid")
hornbillAPI.SetAPIKey("yourHornbillAPIKey")
hornbillAPI.SetJSONResponse(true)
hornbillAPI.SetParam("leftEntityId", "xs:string")
hornbillAPI.SetParam("leftEntityType", "xs:string")
hornbillAPI.SetParam("leftRelType", "xs:string")
hornbillAPI.SetParam("rightEntityId", "xs:string")
hornbillAPI.SetParam("rightEntityType", "xs:string")
hornbillAPI.SetParam("rightRelType", "xs:string")
hornbillAPI.SetParam("dependsOn", "xs:string")
responseBody, apiError := hornbillAPI.Invoke("apps/com.hornbill.servicemanager/Asset", "linkAsset")
if apiError != nil {
fmt.Println(apiError)
return
}
fmt.Println(responseBody)
}
const endpoint = "https://api.hornbill.com/yourinstanceid/xmlmc/apps/com.hornbill.servicemanager/Asset";
const payload = {
"@service": "apps/com.hornbill.servicemanager/Asset",
"@method": "linkAsset",
"params": {
"leftEntityId": "xs:string",
"leftEntityType": "xs:string",
"leftRelType": "xs:string",
"rightEntityId": "xs:string",
"rightEntityType": "xs:string",
"rightRelType": "xs:string",
"dependsOn": "xs:string"
}
};
fetch(endpoint, {
method: 'POST',
headers: {
"Authorization": "ESP-APIKEY yourHornbillAPIKey"
},
body: JSON.stringify(payload)
}).then(res => res.json())
.then(res => console.log(res));
const axios = require('axios');
const endpoint = "https://api.hornbill.com/yourinstanceid/xmlmc/apps/com.hornbill.servicemanager/Asset";
const payload = {
"@service": "apps/com.hornbill.servicemanager/Asset",
"@method": "linkAsset",
"params": {
"leftEntityId": "xs:string",
"leftEntityType": "xs:string",
"leftRelType": "xs:string",
"rightEntityId": "xs:string",
"rightEntityType": "xs:string",
"rightRelType": "xs:string",
"dependsOn": "xs:string"
}
};
const axiosConfig = {
headers: {
"Authorization": "ESP-APIKEY yourHornbillAPIKey"
}
};
axios.post(endpoint, payload, axiosConfig)
.then((res) => {
console.log("RESPONSE RECEIVED: ", res);
})
.catch((err) => {
console.log("AXIOS ERROR: ", err);
})
$endpoint = "https://api.hornbill.com/yourinstanceid/xmlmc/apps/com.hornbill.servicemanager/Asset";
$payload = (object) [
'@service' => 'apps/com.hornbill.servicemanager/Asset',
'@method' => 'linkAsset',
'params' => (object) [
'leftEntityId' => 'xs:string',
'leftEntityType' => 'xs:string',
'leftRelType' => 'xs:string',
'rightEntityId' => 'xs:string',
'rightEntityType' => 'xs:string',
'rightRelType' => 'xs:string',
'dependsOn' => 'xs:string',
]
];
$headers = [
'Authorization: ESP-APIKEY yourHornbillAPIKey',
'Content-Type: application/json'
];
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $endpoint);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$resp = curl_exec($curl);
curl_close($curl);
echo $resp;
$Endpoint = "https://api.hornbill.com/yourinstanceid/xmlmc/apps/com.hornbill.servicemanager/Asset"
$Body = @{
"@service" = "apps/com.hornbill.servicemanager/Asset"
"@method" = "linkAsset"
params = @{
leftEntityId = "xs:string"
leftEntityType = "xs:string"
leftRelType = "xs:string"
rightEntityId = "xs:string"
rightEntityType = "xs:string"
rightRelType = "xs:string"
dependsOn = "xs:string"
}
}
$Header = @{
"Authorization" = "ESP-APIKEY yourHornbillAPIKey"
}
$Parameters = @{
Method = "POST"
Uri = $Endpoint
Headers = $Header
Body = ($Body | ConvertTo-Json)
ContentType = "application/json"
}
Invoke-RestMethod @Parameters
import requests
import json
endpoint = "https://api.hornbill.com/yourinstanceid/xmlmc/apps/com.hornbill.servicemanager/Asset"
headers = {
"Authorization": "ESP-APIKEY yourHornbillAPIKey"
}
payload={
"@service":"apps/com.hornbill.servicemanager/Asset",
"@method":"linkAsset",
"params":{
"leftEntityId":"xs:string",
"leftEntityType":"xs:string",
"leftRelType":"xs:string",
"rightEntityId":"xs:string",
"rightEntityType":"xs:string",
"rightRelType":"xs:string",
"dependsOn":"xs:string",
},
}
response = requests.request("POST", endpoint, json=payload, headers=headers)
print(response.text)
- Version {{docApp.book.version}}
- Node {{docApp.node}} / {{docApp.build}}
In This Document