ContactNow: Using ecnow_datasets API ecnow.php Endpoint for Datasets Management
Objective
To use the API ecnow_datasets to create, read and update datasets, from outside the standard ContactNow agent or admin interface.
Note: 8x8 does not provide programming support for the ContactNow API. However, further API reference material is linked in the Additional Information section at the bottom of this article.
Applies To
- ContactNow
- API
- Dataset Management
Procedure(s)
Access the ContactNow API URL
To access any ContactNow API interface, requests need to have an access token. The token will authorize requests for a particular account for a fixed period of time. By default, these requests are restricted to the internet address that requests the token.
The API url to manage these records is
https://api-106.dxi.eu/ecnow.php?token=[Token]&method=ecnow_datasets&action=[Action]&format=[Format]&raw=1
The ecnow_data API has a number of available functions. The request arguments should be passed as HTTP Post or Get variables. The payload/response from the API can be formatted in either json or xml format. The default is json but this can be modified by the format argument below:
- Format: xml or json
The API will output a number of optional values depending on the request made.
- Success: This shows whether the request succeeded. It will contain a true or false value for json or a 1 or 0 for xml.
- Account ID: This shows the authenticated account that ran the API call.
- Total: Number of records affected.
- Bad: Number of records that failed.
- Key: the uniqueue ID that is returned when creating a new record.
- Error: If the request failed, this field will contain a description of the fault.
Example of JSON Response:
{"success":true, "account_id":"1234", "total":1, "bad":0}
Example of XML Response:
<result> <success>1</success> <account_id>1234</account_id> <total>1</total> <bad>0</bad> </result>
Create a Dataset Using ecnow.php Endpoint
This will create a new record and return its success state and a unique key or any errors in the request. If the record already exists it will add a new record with the current details resulting in duplicate records.
- HTTP Request: POST
- Method: ecnow_records
- Action: create
- Arguments: raw, format
- Payload: import_table, description
POST API call with json:
ecnow.php?token=[Token]&format=[Format]&method=ecnow_datasets&action=create&raw=1
json Pay Load:
[{"description":"baba3", "import_table":"nelsontest"}]
The Response:
{"success":true, "account_id":"10278", "total":1, "bad":0, "key":104}
xml Pay Load:
<easycall> <ecnow_records> <description>Baba3</description> <import_table>nesontest</import_table> </ecnow_records> </easycall>
The Response:
<result> <success>1</success> <account_id>10278</account_id> <total>1</total> <bad>0</bad> <key>104</key> </result>
Reading a Dataset Using ecnow.php Endpoint
Read the data/records of a dataset.
- HTTP Request: GET
- Method: ecnow_datasets
- Action: read
- Arguments: qid (optional), import_table (optional), d_status (optional), dataset (optional)
Example:
https://api-106.dxi.eu/ecnow.php?token=[Token]&format=[Format]&method=ecnow_datasets&action=read&raw=1
json Response:
{"success":true, "total":5, "list":[ {dataset: "1", qid: "642384", d_status: "EXPIRED", d_priority: "80", notes: "Loaded by Importer 2.1", callbacks: "none", crm_account: "0", crm_campaign: "", description: "ECN_Training_Customer_Data (1) (1)", locked: "0", loaddate: "2016-07-25 17:24:46", sourcefile: "ECN_Training_Customer_Data (1) (1).csv", import_table: "nelsontest", campaign: "527220" } ]}
xml Response:
<?xml version="1.0" encoding="utf-8" ?> <result> <success>1</success> <total>1</total> <list> <ecnow_dataset> <dataset>1</dataset> <qid>642384</qid> <d_status>EXPIRED</d_status> <d_priority>80</d_priority> <notes>Loaded by Importer 2.1</notes> <callbacks>none</callbacks> <crm_account>0</crm_account> <crm_campaign/> <description>ECN_Training_Customer_Data (1) (1)</description> <locked>0</locked> <loaddate>2016-07-25 17:24:46</loaddate> <sourcefile>ECN_Training_Customer_Data (1) (1).csv</sourcefile> <import_table>nelsontest</import_table> <campaign>527220</campaign> </ecnow_dataset> </list> </result>
Update a Dataset Using ecnow.php Endpoint
This will update an existing record and return its success state or any errors in the request.
- HTTP Request: POST
- Method: ecnow_datasets
- Action: update
- Arguments: raw, format, id
- Payload: description (optional), qid, dataset (required), d_status (optional LIVE | HOLD | EXPIRED), d_priority (optional)
POST API call with json:
ecnow.php?token=[Token]&format=[Format]&method=ecnow_datasets&action=update&raw=1
json Pay Load:
[{"description":"baba3", "import_table":"nelsontest", "qid":"829603", "dataset":"104", "d_status":"LIVE", "d_priority":"90"}]
The Response:
{"success":true, "account_id":"10278", "total":1,"bad":0}
xml Pay Load:
<?xml version='1.0' encoding='utf-8' ?> <easycall> <ecnow_records> <description>550447</description> <import_table>nelsontest</import_table> <qid>Blogs<qid/> <dataset>104</dataset> <d_status>LIVE</d_status> <d_priority>90</d_priority> </ecnow_records> </easycall>
The Response:
<result> <success>1</success> <account_id>10278</account_id> <total>1</total> <bad>0</bad> <key>0</key> </result>
Additional Information
To create access tokens for the ContactNow API, you will need to create a case with 8x8 Technical Support to obtain an API username and key. Once you have the username and key, you can use the instructions on the following link to create a token for using the API functionality.
The following 8x8 ContactNow API reference material is available to the public. Each link will open a new browser tab: