366 Degrees

366 Web API

Add Contacts

Description:This will add a contact to the open drip campaign in 366 Degrees.
Method: AddContact
URL:https://api.366.io/DripCampaignApis/api/AddContacts
 

Try it out

Sample Code

MVC Code

[HttpPost]
public ActionResult AddContact(Campaign cam)
{
var finalresult = string.Empty;
dynamic json;
try
{
if (!string.IsNullOrEmpty(cam.Authorization))
{
var postReq1 =(HttpWebRequest)WebRequest.Create(ConfigurationManager.AppSettings["AddContacts"].ToString());
postReq1.Method = "POST";
postReq1.ContentType = "application/x-www-form-urlencoded";
postReq1.Headers.Add("Authorization", cam.Authorization);
postReq1.Headers.Add("CampaignId", cam.CampaignId);
postReq1.Headers.Add("UserId", cam.EmailId);
postReq1.Headers.Add("ContactName", cam.ContactName);
var dataStream1 = postReq1.GetRequestStream();
dataStream1.Close();
var response1 = postReq1.GetResponse();
dataStream1 = response1.GetResponseStream();
if (dataStream1 != null)
{
var reader1 = new StreamReader(dataStream1);
string result1 = reader1.ReadToEnd();
reader1.Close();
finalresult = JsonConvert.SerializeObject(result1);
}
}
json = JsonConvert.DeserializeObject(finalresult);
}
catch (Exception ex)
{
throw ex;
}
return Json(json, JsonRequestBehavior.AllowGet);
}

JQuery Code

$('#Dripsubmit').click(function ()
{
var form = $("form");
form.validate();
if (form.valid() && !window.isSubmitted)
{
window.isSubmitted = true;
var cam = {
Authorization: $("#Authorization").val(),
CampaignId: $("#CampaignId").val(),
EmailId: $("#EmailId").val(),
ContactName: $("#ContactName").val() ? $("#ContactName").val() : ""
};
$.ajax({
url: "/OpenDripCampaign/AddContact",
type: "POST",
contentType: "application/json;charset=utf-8",
data: JSON.stringify(cam),
dataType: 'json',
timeout: 1200000,
async: true,
success: function (data) {
var myresult = $.parseJSON(data);
$("#tbloutput").append(" Result: " + myresult + " ");
document.getElementById("Dripsubmit").disabled = true; ");
},
error: function(err)
{
window.isSubmitted = false;
displaySwalMessageWithButton("Please resolve all errors to proceed further.", "Warning");
console.log(err);
}
});
}
});

Json OutPut