I have written a Python script which gets an object type and its attributes from a source tenant and schema then creates the object type and adds its attributes in a target tenant/schema. This works fine for simple attributes but I have run into a roadblock with reference attributes.
The way the script works is that it uses the response body from the GET object type attribute API as the payload to create the attribute in the target object type (after removing some properties such as workspaceId, globalId, id and objectType). For some properties it also must do a transform, for example the GET response has defaultType as a dict so I have to parse out the "id" from the dict and send that in the POST as defaultTypeId.
For reference attributes the GET response has dicts for referenceType and referenceObjectType so when I build the payload I am parsing out the "id" from each and POSTing them as referenceTypeId and referenceObjectTypeId. Using that method I am getting back an HTTP 400 bad request error with this payload though:
{'typeValue': 'Object Type invalid', 'additionalValue': 'ReferenceType invalid'}
Unfortunately the API documentation doesn't either of these properties so I can't even tell if creating a reference attribute with this API is supported. Any suggestions on the proper syntax for the payload? Below is what I am currently sending, I did try sending the referenceTypeId and referenceObjectTypeId as integers instead of strings (even though the GET response returns strings) but still get the same error.
{
'editable': True,
'hidden': False,
'includeChildObjectTypes': False,
'indexed': True,
'label': False,
'maximumCardinality': 1,
'minimumCardinality': 0,
'name': 'Service',
'options': '',
'position': 3,
'referenceObjectTypeId': '1',
'referenceTypeId': '1',
'removable': True,
'sortable': True,
'summable': False,
'system': False,
'type': 1,
'uniqueAttribute': False
}