Question
A customer wants to apply e1 and e2, create a relation between e1 and e2 in the same request for POST {TenantURL}/objects. Is this possible? Is there a sample JSON somewhere?
Answer
If the relationship is defined in a reference attribute you can use a request similar to the following:
POST {{tenantURL}}/entities[
{
"type": "configuration/entityTypes/Contact",
"attributes": {
"FirstName": [
{
"type": "configuration/entityTypes/Contact/attributes/FirstName",
"value": "Jane"
}
],
"LastName": [
{
"type": "configuration/entityTypes/Contact/attributes/LastName",
"value": "Smith"
}
],
"Addresses": [
{
"value": {
"AddressType": [
{
"type": "configuration/entityTypes/Contact/attributes/Addresses/attributes/AddressType",
"value": "Organization/Contact"
}
],
"AddressLine1": [
{
"type": "configuration/entityTypes/Contact/attributes/Addresses/attributes/AddressLine1",
"value": "666 E 75th St"
}
],
"City": [
{
"type": "configuration/entityTypes/Contact/attributes/Addresses/attributes/City",
"value": "Indianapolis"
}
],
"StateProvince": [
{
"type": "configuration/entityTypes/Contact/attributes/Addresses/attributes/StateProvince",
"value": "IN"
}
],
"Country": [
{
"type": "configuration/entityTypes/Contact/attributes/Addresses/attributes/Country",
"value": "United States"
}
],
"PostalCode": [
{
"type": "configuration/entityTypes/Contact/attributes/Addresses/attributes/PostalCode",
"value": "462502805"
}
]
}
}
],
"Product": [
{
"value": {
"Name": [
{
"value": "Pen"
}
],
"SKU": [
{
"value": "PEN-0003"
}
],
"productID": [
{
"type": "configuration/entityTypes/Product/attributes/productID",
"value": "10003"
}
],
"productProperties": [
{
"value": {
"Type": [
{
"value": "Style"
}
],
"Value": [
{
"value": "Ballpoint"
}
]
}
},
{
"value": {
"Type": [
{
"value": "Ink Color"
}
],
"Value": [
{
"value": "Red"
}
]
}
}
],
"Status": [
{
"value": "Active"
}
],
"purchaseDate": [
{
"value": "2019-03-21"
}
]
},
"refEntity": {
"crosswalks": [
{
"type": "configuration/sources/CRM",
"value": "PRD_1000003"
}
]
},
"refRelation": {
"crosswalks": [
{
"type": "configuration/sources/CRM",
"value": "CON_PRD_1000003"
}
]
}
}
]
},
"crosswalks": [
{
"type": "configuration/sources/CRM",
"value": "CON_1000003",
"createDate": "2017-01-01T08:00:00.000Z",
"updateDate": "2017-02-01T08:00:00.000Z",
"sourcePublishDate": "2017-03-01T08:00:00.000Z"
}
]
}
]
In this example, a contact and a product entity will be created if they do not already exist, linked by a relationship. If the entities are not linked by a reference attribute, then you will have to perform separate requests to create each entity and then link them.
Comments
Please sign in to leave a comment.