How to set the value of metadata related to specific entities

In order to set the value of a metadata (or a set of metadata) for a given entity (or a set of entities) the first thing to do is to make sure that the specific metadata (or the set of metadata) is included in at least one of the tags which have been added to the target entity. The operation can be performed only by users with specific permission to assign tags. The following are all the available cases which can be performed via web services.

 

One to one: set the value of a specific metadata for a specific entity

 

In order to perform this operation you will have to use the insert web services which can be found in the imetadata package of xintelligence. Required parameters which must be included in the header of the request are:

  • X-TOKENID: a valid platform token related to a user with required permission.
  • clientId: the domain name used to access THRON, usually your company name.
  • classificationId: the ID of the class in which the tag and the specific metadata have been defined.

In the body of the request you can paste the following JSON, filling required parameters:


{
    "imetadata": {
        "key": "",
        "value": "",
        "lang": ""
    },
    "target": {
        "id": "",
        "entityType": ""
    }
}

 

Where:

  • key: string, mandatory. It is the identifier of the metadata itself. Constraints: max length = 50 characters only letters and digits.
  • value: string, optional. It is the value to be set on the specific metadata. Max length is based on metadata type (see metadata definition constraints at Developer Portal). 
  • langstring, optional. It is the code of the language for the metadata value (ISO639-1).
  • idstring, mandatory. It is the unique identifier of the target (xcontentId, contactId)
  • entityType: string, mandatory. It is the type of entity of the target. Can be "CONTENT" or "CONTACT".

 

Please note that if the specific metadata is monolingual, the "lang" parameter must be omitted.

The web service which can be used to revert the operation and delete the value of the specific metadata is remove.

 

Many to one: set the value of a specific set of metadata for a specific entity

 

In order to perform this operation you will have to use the bulkinsert web services which can be found in the imetadata package of xintelligence. Required parameters which must be included in the header of the request are:

  • X-TOKENID: a valid platform token related to a user with required permission.
  • clientId: the domain name used to access THRON, usually your company name.
  • classificationId: the ID of the class in which the tag and the specific metadata have been defined.

In the body of the request you can paste the following JSON, filling required parameters:


{
    "value": {
        "imetadata": [{
            "key": "",
            "value": "",
            "lang": ""
        }, {
            "key": "",
            "value": "",
            "lang": ""
        }],
        "target": {
            "id": "",
            "entityType": ""
        }
    }
}    

Please note that if the specific metadata is monolingual, the "lang" parameter must be omitted.

The web service which can be used to revert the operation and delete the value of the specific set of metadata is bulkRemove.

 

One to Many: set the value of a specific metadata for a specific set of entities

 

In order to perform this operation you will have to use the bulkInsertMultiTargets web services which can be found in the imetadata package of xintelligence. Required parameters which must be included in the header of the request are:

  • X-TOKENID: a valid platform token related to a user with required permission.
  • clientId: the domain name used to access THRON, usually your company name.
  • classificationId: the ID of the class in which the tag and the specific metadata have been defined.

In the body of the request you can paste the following JSON, filling required parameters:


{
    "value": {
        "imetadata": {
            "key": "",
            "value": "",
            "lang": ""
        },
        "targets": [{
            "id": "",
            "entityType": ""
        }, {
            "id": "",
            "entityType": ""
        }]
    }
}    

You can set the value of the specific metadata for a maximum number of 50 entities of the same type.

The web service which can be used to revert the operation and delete the value of the specific metadata is bulkRemoveMultiTargets.

 

Update metadata value

 

To change the value of a previously valued metadata, the service to be invoked is imetadata/update. The url of the webservice is structured as follows:

//<clientId>-view.thron.com/api/xintelligence/resources/imetadata/update/<clientId>/<classificationId>

In the body of the request you can paste the following JSON, filling required parameters:


{
  "imetadata": {
    "key": "",
    "value": "",
    "lang": ""
  },
  "target": {
    "id": "",
    "entityType": ""
  }
}

Where:

  • key: is the key of the metadata to be updated. 
  • value: is the new value to be set to the specific metadata.
  • lang: the language for which the new value has to be set (ISO639-1).
  • id: the id of the target; can be either an xcontentId, a username or a contactId.
  • entityType: the type of entity for which the new value is set; can either be CONTENT, USER or CONTACT.
Was this article helpful?
0 out of 0 found this helpful

Have any question?

Open a ticket
Comments