Hi all, I was able to successfully add external contacts with the Java SDK without custom attributes. Next I tried to change my code to use custom attributes while adding an external contact but I keep running into the same error message "A schema ID must be specified when using customFields".
Sample response body:
Body: {"message":"A schema ID must be specified when using customFields.","code":"custom.fields.validation.failed","status":422,"contextId":"df740c6f-fa0f-4aea-8998-e6bd55520a33","details":[],"errors":[]}
I suspect I know why this fails but the Java SDK does not allow me to specify the ID the API expects (or I do something incorrectly...).
The documentation at https://developer.genesys.cloud/api/rest/v2/externalcontacts/overview states that SchemaID and version must be present but the Java SDK only allows schema name (NOT ID) and version.
This is what my code sends out:
Body: {"firstName":"SDKxxx firstname","lastName":"SDKxxx lastname","workEmail":"workxxx@sdk.java","address":{"address1":"sdkxx address line 1"},"schema":{"name":"8281d305-5e94-4dbe-9384-65c2419bc9a1","version":3,"appliesTo":[],"enabled":true},"customFields":{"ouc_text":"aaaaaa","ein_text":"11111","works_manager_id_text":"bbbbbbb"},"externalDataSources":[]}
Notice that it has name but not ID and I believe this is why it fails but I can't find a way to use ID instead of name using the SDK. This is how it should look like (from the above documentation):
"schema": {
"id": "dfaefb61-d0a8-4ddb-89e3-016c5f71ce70",
"version": 1
}
This is my Java code for this:
DataSchema dataSchema = new DataSchema();
dataSchema.setName("8281d305-5e94-4dbe-9384-65c2419bc9a1");
dataSchema.setVersion(3);
dataSchema.setEnabled(true);
Map<String, Object> customData = new HashMap<String, Object>();
customData.put("ein_text", "11111");
customData.put("ouc_text", "aaaaaa");
customData.put("works_manager_id_text", "bbbbbbb");
ContactAddress contactAddress = new ContactAddress();
ExternalContact externalContactToAdd = new ExternalContact();
externalContactToAdd.setFirstName("SDKxxx firstname");
externalContactToAdd.setAddress(contactAddress);
externalContactToAdd.setSchema(dataSchema);
externalContactToAdd.setCustomFields(customData);
PostExternalcontactsContactsRequest postExternalcontactsContactsRequest = PostExternalcontactsContactsRequest.builder().withBody(externalContactToAdd).build();
ExternalContact externalContactCreated = externalContactsApi.postExternalcontactsContacts(postExternalcontactsContactsRequest);
the dataSchema give me setName and setVersion methods but not setID as such I am unable to set id to be added to the schema.
Am I missing something or maybe this is an issue with the Java SDK (setting name but the API expects iD?)
thanks,
Zsolt