cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1997
Views
20
Helpful
12
Replies

Uploading contacts through CSV file through configuration API

Jenni
Level 1
Level 1

Hi ,

I am trying to upload the contacts through csv file as per the below specification.

https://developer.cisco.com/docs/contact-center-express/#!add-contacts-to-campaign/input-xml-example-1

 

Adding the contacts through input xml example 1 is working fine. But while I am trying upload the contacts through csv file as per the input-xml example-2 I am getting below error.

 

{
    "apiError": [
        {
            "errorData""",
            "errorMessage""\nException Description: An error occurred marshalling the object\nInternal Exception: org.xml.sax.SAXParseException; cvc-complex-type.2.4.b: The content of element 'campaignContacts' is not complete. One of '{csvdata}' is expected.",
            "errorType""InvalidInput"
        }
    ]
}
 
The request sent is as follows
<campaignContacts>
    <campaign name="Test">
        <refURL>https://uccxserver/adminapi/campaign/2</refURL>
    </campaign>
    <allowDuplicateContacts>true</allowDuplicateContacts>
        <csvFileData>
            <csvFileRef>E:\Contacts.csv</csvFileRef>
            <importType>AUTO</importType>
            <contactHeaders>
                <header1>Account Number</header1>
                <header2>First Name</header2>
                <header3>Last Name</header3>
                <header4>Phone1</header4>
                <header5>Phone2</header5>
                <header6>Phone3</header6>
                <header7>Dial Time</header7>
            </contactHeaders>
        </csvFileData>
</campaignContacts>

 

The csv file has following sample entries

ABCD1234, John , Doe, 1401111, 1402222, 1403333, 12:35
ABCD1235, Jane , Smith, 1504444, 1505555, 1506666, 12:35

 

I am not sure what I am missing . Same data, sent through input xml format is working well. But problem is through csv file.

 

Any input on this is highly appreciated.

 

Thanks,

Jenny!

 

1 Accepted Solution

Accepted Solutions

It will be hard to guess the data structure on the API without documentation. The quickest option would be to open a TAC case and request for the DOC update to fill data-structure gaps.

Marek
Web: https://gaman-gt.com

View solution in original post

12 Replies 12

Hi Jenny,

I think that the problem might be with this reference:

<csvFileRef>E:\Contacts.csv</csvFileRef>

Marek
Web: https://gaman-gt.com

Hi Jenny,

I think that the problem you are getting is related to the following line:

<csvFileRef>E:\Contacts.csv</csvFileRef>

You are using paths relative to your workstation but in my opinion, UCCX will try to find the pointed file in his file repo. The message also confirms that it's probably unable to load the file. What would be helpful in this are the logs from UCCX. I think that you should try to (but this is only a guess):

  • use the API and upload the file to UCCX, but the question is where? The provided DOC doesn't say a word where to put the file but I would try to upload using FIle API. Probably UCCX logs could tell you more.
  • Once the file is uploaded - trigger the import API.

 

Marek
Web: https://gaman-gt.com

Hi Merek,

Thank you so much for the quick response. I am trying to upload the contacts list from an application server to the outbound campaign of uccx server. When I manually upload this contact list through a csv file its working. We would like to automate the process that's why trying to make use of the API.

If the location is a problem, the API is not throwing any error about that . However I will try to dig into uccx logs.

A quick update after I posted my query. looks to be <csvdata> is mandatory field and its headers as well. if I don't add csvdata the previously mentioned error is thrown. if I add empty data, the below error is thrown

{
    "apiError": [
        {
            "errorData""csvdata",
            "errorMessage""Contacts header is missing in payload",
            "errorType""InvalidInput"
        }
    ]
}
 
so updated the request like this
"
<?xml version="1.0" encoding="UTF-8"?>
<campaignContacts xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="campaignContacts.xsd">
    <campaign name="Test3">
        <refURL>https://uccxserver/adminapi/campaign/2</refURL>
    </campaign>
    <allowDuplicateContacts>true</allowDuplicateContacts>
  <csvdata>Account Number, First Name, Last Name ,Phone1, Phone2, Phone3, Dial Time</csvdata>
        <csvFileData>
            <csvFileRef>E:\Contacts.csv</csvFileRef>
            <importType>AUTO</importType>
            <contactHeaders>
                <header1>Account Number</header1>
                <header2>First Name</header2>
                <header3>Last Name</header3>
                <header4>Phone1</header4>
                <header5>Phone2</header5>
                <header6>Phone3</header6>
                <header7>Dial Time</header7>
            </contactHeaders>
        </csvFileData>
</campaignContacts>
"

The success response is received with status code 200 

{
    "campaign": {
        "@name""Test",
        "refURL""https://uccxserver/adminapi/campaign/2"
    },
    "csvdata"""
}
But it s not at all trying to refer the csv file. May be I m missing something.
 
 

 

Jenni,

I think that I have the answer for you. Here is a link that list all the pdf files that describe the UCCX API's: https://developer.cisco.com/docs/contact-center-express/#!previous-documentation-pdfs

 

I've gone through the "Unified CCX Configuration API Documentation" documents and it looks like import that uses"Input 2" content has been introduced in version 12.0. It is not presented in an earlier version.

What is also interesting, the data structure described in the chapter "Data Structure for Campaign Contacts" doesn't cover the new parameters. It's probably a bug.

After the discovery, I did some additional tests on UCCX v12.0. Here is a screenshot from Postman:

 

CampaignContacts_1.png

The problem that you experienced, disappeared. That confirmed the initial finding - Input 2 - is a feature introduced in version 12.0. Older versions don't support it generating the error message (below).

 

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<apiErrors>
    <apiError>
        <errorData></errorData>
        <errorMessage>
Exception Description: An error occurred marshalling the object
Internal Exception: org.xml.sax.SAXParseException; cvc-complex-type.2.4.b: The content of element 'campaignContacts' is not complete. One of '{csvdata}' is expected.</errorMessage>
        <errorType>InvalidInput</errorType>
    </apiError>
</apiErrors>

I can say that my initial answer was not right, as you stated @Jenni. The error indicates the provided input data structure is invalid and is missing tag <csvData>.

 

 

 

 

Marek
Web: https://gaman-gt.com

Hi Merek,

 

Thank you so much for the extensive analysis you have made. Yes, as per the reference documents you have shared, the method of uploading the csv file itself not at all supported in the version 11.0 which my site environment would be. So I have to try the possibilities of uploading contacts through the first method itself in a 2 step process, reading from local csv and sending to add contacts method.

 

However, I wonder if any specific details shared in 12.0 about the location of csv file etc in detail for our understanding.

 

Thanks,

Jenny!

It will be hard to guess the data structure on the API without documentation. The quickest option would be to open a TAC case and request for the DOC update to fill data-structure gaps.

Marek
Web: https://gaman-gt.com

Yes..You are right. we could not do the guess work here. Thank you so much.

I will try to implement with available method itself, if I face issue with that too, I would raise the TAC.

 

Thanks!

Jenny.

To troubleshoot the API you can use and collect logs using RTMT and choosing "Cisco Unified CCX Administrator".

 

I did some further tests on UCCX 12.0.1.100000-24 and it seems that this version seems to be buggy. Every time when I send the request (Input 2 schema) I'm getting the same answer:

{
    "apiError": [
        {
            "errorData": "csvdata",
            "errorMessage": "Mandatory header \"phone1\" is not specified in contact headers.",
            "errorType": "InvalidInput",
            "i18n": {
                "key": "adminapi.contacts.phone1.missing",
                "args": {
                    "arg": [
                        "PHONE1"
                    ]
                }
            }
        }
    ]
}

What is interesting is what I see in the logs.

 

This is the place when the import is triggered (no errors):

11988: Jan 25 06:34:10.129 UTC %MADM-UCCX_WEBSERVICES-7-UNK: [http-bio-443-exec-1] com.cisco.uccx.ServiceLogger UccxApiAuthFilter.doFilter:In SecurityFilter: doFilter()
11989: Jan 25 06:34:10.129 UTC %MADM-UCCX_WEBSERVICES-7-UNK: [http-bio-443-exec-1] com.cisco.uccx.ServiceLogger Request Url: https://198.18.133.19/adminapi/campaign/14/contacts
11990: Jan 25 06:34:10.129 UTC %MADM-UCCX_WEBSERVICES-7-UNK: [http-bio-443-exec-1] com.cisco.uccx.ServiceLogger UccxApiAuthFilter.doFilter:Request needs to be authenticated
11991: Jan 25 06:34:10.129 UTC %MADM-UCCX_WEBSERVICES-7-UNK: [http-bio-443-exec-1] com.cisco.uccx.ServiceLogger UccxApiAuthProvider.authenticate: authorization is Basic
11992: Jan 25 06:34:10.129 UTC %MADM-UCCX_WEBSERVICES-7-UNK: [http-bio-443-exec-1] com.cisco.uccx.ServiceLogger Trying to retrieve principal with user id Administrator
11994: Jan 25 06:34:10.132 UTC %MADM-UCCX_WEBSERVICES-7-UNK: [http-bio-443-exec-1] com.cisco.ccbu.uccx.adminapi.common.log.AdminapiLogger addContactsToCampaign in campaignId: 14

Here is a place where the server-side extracts the provided header description (I've marked the header in red):

12002: Jan 25 06:34:10.143 UTC %MADM-UCCX_WEBSERVICES-7-UNK: [http-bio-443-exec-1] com.cisco.ccbu.uccx.adminapi.common.log.AdminapiLogger getCSVHeaders headers: None,None,None,None,None,None,None

As you can see although the header is provided as in sample, the server-side doesn't see the defined column names. This finally generates an exception:

12022: Jan 25 06:34:10.172 UTC %MADM-UCCX_WEBSERVICES-7-UNK: [http-bio-443-exec-1] com.cisco.ccbu.uccx.adminapi.common.log.AdminapiLogger CampaignValidator.validateInputContactsXml() - Mandatory header (phone1 is not specified in contacts headers (None,None,None,None,None,None,None)
12023: Jan 25 06:34:10.172 UTC %MADM-UCCX_WEBSERVICES-7-UNK: [http-bio-443-exec-1] com.cisco.ccbu.uccx.adminapi.common.log.AdminapiLogger addContactsToCampaign BaseException: : Exception=com.cisco.ccbu.uccx.adminapi.common.InvalidInputException
12024: Jan 25 06:34:10.172 UTC %MADM-UCCX_WEBSERVICES-7-EXCEPTION:com.cisco.ccbu.uccx.adminapi.common.InvalidInputException
12025: Jan 25 06:34:10.173 UTC %MADM-UCCX_WEBSERVICES-7-EXCEPTION:	at com.cisco.ccbu.uccx.adminapi.resources.campaign.CampaignInputDataValidator.validateContactHeaders(CampaignInputDataValidator.java:607)
12026: Jan 25 06:34:10.173 UTC %MADM-UCCX_WEBSERVICES-7-EXCEPTION:	at com.cisco.ccbu.uccx.adminapi.resources.campaign.CampaignResource.addContactsToCampaign(CampaignResource.java:506)
12027: Jan 25 06:34:10.173 UTC %MADM-UCCX_WEBSERVICES-7-EXCEPTION:	at sun.reflect.GeneratedMethodAccessor265.invoke(Unknown Source)
....................

So even if this API is introduced, it doesn't work in UCCX 12.0.1.100000-24.

Marek
Web: https://gaman-gt.com

I wonder, what is the purpose of having this API if its not in working format.

May I understand where do you place the Csv file (uccxserver)? Could you find any logs referring the path of the csv file. I could not test this as I don't have 12.0 environment as of now. However your inputs are very helpful. Thank you.

Jenny,

I didn't reached to the part where I pass the file to UCCX. At this stage, the error appears in the stage where the UCCX checks the content of the request and it fails. I don't see any info/reference where the file should be placed.

Marek
Web: https://gaman-gt.com

Okay. As of now , we can conclude that uploading through csv is not supported and proceed on alternate approach.

Thank you Marek.

Merek,

 

For json parsing I have used jackson jars and when try to upload the custom jar and jackson jars, application service not starting

What might be the issue ? Any experience in this?

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: