Export management
Export management
The export module allows you to export a list of emails with their fields. And to define the exported population, you use a target created before.
info
Vous trouverez la documentation pour créer une cible ici.
To create a subscriber export, you must use the POST api/{idsite}/exports/subscribers call.
The parameters to specify in the url are the following:
Name | Description | Type | Additional information |
---|---|---|---|
idsite | MindBaz site identifier | Integer | Mandatory |
In the query body, the parameters to be passed in the form "application/json, text/json " are as follows:
Name | Description | Type | Additional information |
---|---|---|---|
compress | Indicates how to compress the data. | ECompressionMode | None |
filename | Indicates the name of the file to be exported. A suffix is added automatically at the end of the file name in the form yyyyMMddHHmmss. The csv extension is added automatically. The final file name will therefore be in the form "myFilename_yyyyMMddHHmmss.csv".You can also export to a sub-directory by specifying it in filename. e.g. "myDirectory\myFilename". Attention, the directory must already be created. | Character string | None |
idRepository | Id of an external sftp to mindbaz to drop the file. To get the list of repositories, you can call GET /api/{idsite}/exports/repositories. To add more repositories, you need to make a request to customer service. | Integer | null for the default storage. |
idsFields | Indicates the list of fields to insert in the export. | Collection of String | Mandatory |
idTarget | Indicates the target identifier. | Integer number | Mandatory |
quantity | Indicates the number of rows to export, 0=all. | Integer | None |
Indicates how to export the list type fields. | ETypeList | Mandatory | |
encoding | Indicates how data is encoded. | EEncodingType | Mandatory |
idsEncodeFields | Indicates the list of fields to be encoded in a column (placed in the last position of the file). The provided fields will be concatenated and then hashed according to the algorithm defined in the encoding parameter. e.g. if I want to have a column with an md5 hash corresponding to email+lastname+firstname, I must set idsEncodeFields = [1,14,15] and encoding="MD5". the new column will have as its name the type used for the hash (MD5 in the example). Attention, the order of the fields is important! | Collection of String | None |
The type ECompressionMode is of type Enum:
Name | Value | Description |
---|---|---|
GZip | 1 | GZip compression |
Zip | 2 | Zip compression |
The EEncodingType is of type Enum:
Name | Value | Description |
---|---|---|
None | 0 | No encoding, plain text |
MD5 | 1 | Hash MD5 |
SHA1 | 2 | Hash SHA1 |
SHA2_256 | 3 | Hash SHA256 |
SHA2_512 | 4 | Hash SHA512 |
The ETypeList is of type Enum:
Name | Value |
---|---|
ID | 0 |
VALUE | 1 |
{
"idTarget": 1161,
"idsFields": ["0", "1"],
"filename": "test_export_api",
"quantity": 0,
"typeList": "ID",
"compress": "GZip",
"encoding": "None",
"idRepository": 0
}
On return call I get the information of the newly created export:
{
"success": true,
"data": true,
"error": null,
"typeName": "Boolean"
}
Codeline
- C#
- Java
- Python
string token = ""; //Value of the token retrieved for authentication
string idSite = ""; //Value of the site id
var client = new RestClient("https://api.mindbaz.com/api/" + idSite + "/exports/subscribers");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer " + token);
var body = @"{""idTarget"": 1161,""idsFields"": [""0"",""1""],""filename"": ""test_export_api"",""quantity": 0,""typeList": ""ID",""compress": ""GZip"",""encoding": ""None"",""idRepository"": 0 }";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://api.mindbaz.com/api/{idsite}/exports/subscribers")
.header("Content-Type", "application/json")
.header("Authorization", "Bearer `TOKEN`")
.body("{\"idTarget\": 1161,\"idsFields\": [\"0\",\"1\"],\"filename\": \"test_export_api\",\"quantity\": 0, \"typeList\": \"ID\",\"compress\": \"GZip\",\"encoding\": \"None\",\"idRepository\": 0 }")
.asString();
import http.client
import json
conn = http.client.HTTPSConnection("api.mindbaz.com")
payload = json.dumps({
"idTarget": 1161,
"idsFields": [
"0",
"1"
],
"filename": "test_export_api",
"quantity": 0,
"typeList": "ID",
"compress": "GZip",
"encoding": "None",
"idRepository": 0
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer `TOKEN`'
}
conn.request("POST", "/api/{idsite}/exports/subscribers", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))