Importing of multiple contacts via API has made easy. There are two APis that you can use, one is to provide contact details in an array and the other is using the APi that would help you use the CSV file in a parameter to import sizable amount of contacts via APi. Earlier is discussed in a separate article, latter "Importing Via CSV" APi is discussed in the following area.
Username |
The email that account holder uses to login MUMARA |
API Token |
The API token user has generated using API Configuration section of MUMARA, also mentioned above. |
Method |
Method being called (Post) |
Path |
Path to the API file being called ('http//www.yourdomain.com/API/addSubscriber) |
Make sure you have a .CSV file ready and uploaded to provide the qualified path for sending an APi Request. In the following sample request, this is an example of the path yourdomain.com/list.csv
Note: Since you can't map the header values of the importing file and the fields within the system in case of importing contacts via APi function, therefore, double check the header values of the .CSV file should match the exact system fields to add the information correctly. E.g. if in system you have a field called First Name, the .CSV file should have the first name values arranged under the same header First Name.
Provide a list_id as required parameter for the system to identify the list for purpose of adding contacts information. You will end upon at an error response if the list_id you provided is wrong or doesn't exist.
<?php
set_time_limit(0);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://yourdomain.com/API/addSubscriber');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1200);
curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'file_path' => "http://mydomain.com/list.csv",'list_id' =>16));
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'APIToken: 343b1b831067b50e308e6bf93e0f06f0', 'Login: [email protected]'));
$data = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (curl_errno($ch)) {
print "Error: " . curl_error($ch);
} else {
// Show me the result
print ($data);
curl_close($ch);
}
?>
A text based response with "Success" status will be returned upon submitting a request with right parameters, valid end point and API key. The text based message would show you the number of contacts added to the desired list from the total number of contacts in the .CSV file.
A text based response providing the reason of the error. i.e.
{"status":"error","response":"List not available to add subscriber"}