Here's the code our developer is using:
var client = new RestClient("https://[REDACTED}.mktorest.com/");
var identityRequest = new RestRequest("identity/oauth/token");
identityRequest.AddParameter("grant_type", "client_credentials");
identityRequest.AddParameter("client_id", @"[REDACTED FOR THIS POST]");
identityRequest.AddParameter("client_secret", @"[REDACTED FOR THIS POST]");
var identityResponse = client.Execute<AuthResponse>(identityRequest);
if (identityResponse.Data != null)
{
var accessToken = "?access_token=" + identityResponse.Data.access_token;
var leads = new Leads
{
action = "createOrUpdate",
input = new List<Lead>()
{
new Lead()
{
email = "test@abc.com",
firstName = "test",
postalCode = "11111",
company = "Test"
}
}
};
var leadsRequest = new RestRequest("rest/v1/leads.json" + accessToken, Method.POST);
leadsRequest.RequestFormat = DataFormat.Json;
leadsRequest.AddBody(leads);
var leadsResponse = client.Execute(leadsRequest);
//var campaignRequest = new RestRequest("rest/v1/campaigns.json" + accessToken);
//campaignRequest.RequestFormat = DataFormat.Json;
//var campaignsResponse = client.Execute(campaignRequest);
}
The response is:
This gives me a server response:
{"requestId":"ddb4#147b1e9ab08","success":false,"errors":[{"code":"1006","message":"Field 'Company' not found"}]}
PM me if you need the full, uncensored info that I'm using.
Robb Barrett