Add Contact To List Error

Hi All
Evet time I attempt to use the API to add a single contact to a list I get a "columns do not match" error. I'm using the following on the API explorer
/api/v2/outbound/contactlists/{contactListId}/contacts

[
{
"data": {
"Name": "Bob",
"Number": "254545"
},
"contactListId": "3fb33e67-58ea-40d2-a4c2-9647b819549a",
"callable": true
}
]

and getting this error
{
"message": "The contact columns do not match what is required in the list",
"code": "invalid.contact.columns",
"status": 400,
"messageWithParams": "The contact columns do not match what is required in the list",
"messageParams": {
"columnName": "[Name, Number]"
},
"contextId": "084b4b72-59a0-4c1f-a2a8-8bd19b26592f",
"details": [],
"errors": []
}

And this is part of the get contact list:
"division": {
"id": "860274fd-9263-4e3c-860b-4d53486a5dd3",
"name": "Dev",
"selfUri": "/api/v2/authorization/divisions/860274fd-9263-4e3c-860b-4d53486a5dd3"
},
"columnNames": [
"Name",
"Number",
"PHONE1",
"PHONE2",

Hope its something very simple!

Hello

In your request body you provided columns "Name" and "Number", but I can see that the contact list also has columns "PHONE1" and "PHONE2". If you provide values for these columns as well, it should work.

-Charlie

Sorry Charlie, I get the following:
"message": "The contact columns do not match what is required in the list",
"code": "invalid.contact.columns",
"status": 400,
"messageWithParams": "The contact columns do not match what is required in the list",
"messageParams": {
"columnName": "[Name, Number, PHONE1, PHONE2]"
},
"contextId": "69ab3dde-c6d7-4102-833b-f026207399be",
"details": [],
"errors": []
}

I noticed you only pasted as far as here what you got back from the call to GET .../contactlist/{contactListId}. Could you confirm that the array does in fact end there? If you could post the whole response, that would help debug things.

Thanks

Just had a light bulb moment thanks to your last comment - I have to add all columns don't I rather than just the ones I want to update!
Tried and tested ok.

Many Thanks
Phil

1 Like

Yes, I wasn't clear enought. That's what I meant to say in the first response.

Glad it's resolved!

No perfectly clear, only now when I add to a data action I get :
Validate output against schema: JSON failed output schema validation for the following reasons: instance type (array) does not match any allowed primitive type (allowed: ["object"])

I may just log off for the day

If possible, could you post the exported json config of the data action so I can check it out? Just be careful to not post any sensitive information.

Here you go:
{
"name": " - Exported 2023-09-08 @ 8:20",
"integrationType": "purecloud-data-actions",
"actionType": "custom",
"config": {
"request": {
"requestUrlTemplate": "/api/v2/outbound/contactlists/1d22020d-8db3-48fc-8d18-85b4656eb5a0/contacts",
"requestType": "POST",
"headers": {},
"requestTemplate": "[\n {\n "data": {\n "Name": "Ben",\n "Number": "2225645"\n },\n "contactListId": "1d22020d-8db3-48fc-8d18-85b4656eb5a0",\n "callable": true,\n "phoneNumberStatus": {}\n }\n]"
},
"response": {
"translationMap": {},
"translationMapDefaults": {},
"successTemplate": "${rawResult}"
}
},
"contract": {
"input": {
"inputSchema": {
"title": "Contact",
"type": "object",
"properties": {},
"additionalProperties": true
}
},
"output": {
"successSchema": {
"type": "object",
"properties": {},
"additionalProperties": true
}
}
},
"secure": false
}

The issue is coming from the output validation. The json response from the POST request comes as an array of objects [{...}] but your contract output was build to handle an object {}
Changing your contract output to look like this should solve the problem:

{
  "type": "array",
  "properties": {},
  "items": {
    "title": "Item 1",
    "type": "object",
    "properties": {},
    "additionalProperties": true
  }
}

1 Like

Superb, thank you for your patience

1 Like

On this same API, any help with Python would be great. I get a similar error and the Python examples never provide enough information to work correctly.

Please provide a basic example of adding a first name, last name, phone best, and time zone. What is the format, thanks!

Genesys-Provided:

create an instance of the API class

api_instance = PureCloudPlatformClientV2.OutboundApi();
contact_list_id = 'contact_list_id_example' # str | Contact List ID
body = [PureCloudPlatformClientV2.WritableDialerContact()] # list[WritableDialerContact] | Contact
priority = True # bool | Contact priority. True means the contact(s) will be dialed next; false means the contact will go to the end of the contact queue. (optional)
clear_system_data = True # bool | Clear system data. True means the system columns (attempts, callable status, etc) stored on the contact will be cleared if the contact already exists; false means they won't. (optional)
do_not_queue = True # bool | Do not queue. True means that updated contacts will not have their positions in the queue altered, so contacts that have already been dialed will not be redialed. For new contacts, this parameter has no effect; False means that updated contacts will be re-queued, according to the 'priority' parameter. (optional)

try:
# Add contacts to a contact list.
api_response = api_instance.post_outbound_contactlist_contacts(contact_list_id, body, priority=priority, clear_system_data=clear_system_data, do_not_queue=do_not_queue)
pprint(api_response)
except ApiException as e:
print("Exception when calling OutboundApi->post_outbound_contactlist_contacts: %s\n" % e)

Hi,

Would you be able to create a new topic for your question and also could you include the error that you are getting?

Thanks,
Declan

Sure thing, thanks!

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.