UpdateSubscriber
Update data for an existing subscriber.
URL | https://api.enginemailer.com/restapi/subscriber/emsubscriber/updateSubscriber |
Method | HTTP POST |
Table: Parameter
Parameter name | Description | Column Type |
---|---|---|
SubscriberData | A list of subscriber data. | JSON String |
Table: Data Definition for JSON
Parameter name | Description | Column Type | Maximum Length | Required? |
---|---|---|---|---|
Subscriber Email | String |
128 | Yes | |
SubCategories | List of sub categories id of the subscriber. It is pre-defined in the portal and it can be retrieved by invoking getSubCategory method. | JArray (Int) |
No | |
CustomFields | The custom field value of the subscriber. All the custom field value must be in correct format based on their field type. | Jarray (JObject) |
No | |
SubCategories_type |
Sub Categories Insertion Type 0 - Do nothing to current subscriber. 1- Append the current sub categories. 2- Delete sub categories from the sub categories provided from a subscriber. 3- Replace new sub categories provided to the old one. |
Integer |
No(Default is 1) | |
customfield_type |
Custom Field Update Type 0 - Update specific custom field value. 1- Replace new custom field provided to the old one. |
Integer |
No(Default is 1) |
Table: Custom Fields Data Type
Data Type | Expected Value Format | Maximum Length |
---|---|---|
Date (Not Date Range) |
dd MMM yyyy eg. 01 Jan 2017 |
|
Date (Date Range) |
dd MMM yyyy – dd MMM yyyy eg. 01 Jan 2017 – 02 Jan 2017 |
|
Phone |
Contact Number come with the plus sign with the country code. eg. +60146666666 |
|
Numeric |
Integer value. |
|
Longtext |
<String> |
512 |
Address |
<String> |
512 |
Dropdown |
<String> |
64 |
Checkbox |
Checkbox can have multiple value, the value is separated by | eg. <String>|<String>|<String> |
64 |
Request Example
Header
<APIKEY> - Value
Body
{
"email":"example@enginemailer.com",
"subcategories_type":1,
"subcategories":[ 1, 2 ],
"customfield_type":1,
"customfields":[
{ "customfield_key":"branch", "customfield_value":"KL" },
{ "customfield_key":"mobile", "customfield_value":"+60123456789" },
{ "customfield_key":"hobbies", "customfield_value":"Eating|Sleeping" }
]
}
Response
Success Response
{
"Result":{
"Status":"OK",
"StatusCode":"200"
}
}
Failed Response
{
"Result":{
"StatusCode":"500",
"Status":"InternalServerError",
"ErrorMessage":"Authentication Failed!"
}
}
Code Example (.NET)
JArray subcategory = new JArray();
subcategory.Add(1);
subcategory.Add(2);
JObject jObject = new JObject();
JArray customfield = new JArray();
JObject customfield1 = new JObject();
JObject customfield2 = new JObject();
customfield1.Add("customfield_key", "branch");
customfield1.Add("customfield_value", "Sydney");
customfield.Add(customfield1);
customfield2.Add("customfield_key", "mobile");
customfield2.Add("customfield_value", "+60123456789");
customfield.Add(customfield2);
customfield3.Add("customfield_key", "hobbies");
customfield3.Add("customfield_value", "Eating|Sleeping");
customfield.Add(customfield3);
jObject.Add("email", "example@weblite.com.my");
jObject.Add("subcategories", subcategory);
jObject.Add("subcategories_type", 1);
jObject.Add("customfield_type", 1);
jObject.Add("customfields", customfield);
var client = new RestClient("http://api.enginemailer.com/RESTAPI/subscriber/emsubscriber/updateSubscriber");
var request = new RestRequest(Method.POST);
request.AddHeader("APIKey", "<>");
request.AddParameter("email", jObject.ToString(), ParameterType.RequestBody);
var response = client.Execute(request).Content;
var response2 = JObject.Parse(response);