Mautic Community Forums

Return response 201 on request made for new lead by REST API but no such Lead is displaying

We have implement Mautic REST API for perform basic operation.We wrote code for Create New Lead as below .We also got response 201 that stated that Lead is created but when i show in account there are no such new leads are created as I passed as parameter.Please suggetst.



var baseUrl = new Uri(baseurl);

var client = new RestClient(baseUrl)

{

Authenticator = OAuth1Authenticator.ForRequestToken(consumerKey, consumerSecret)

};

var request = new RestRequest(“api/leads/new”, Method.POST);

client.Authenticator = OAuth1Authenticator.ForProtectedResource(consumerKey, consumerSecret, oauthToken,

oauthTokenSecret);

request.AddHeader(“owner”, “1”);

request.AddHeader(“email”, "ntest@test.com");

request.AddHeader(“lastname”, “ntest”);

request.AddHeader(“firstname”, “ntest”);



// Expected Response Code: 201 for Successfully Lead Creation.

var response = client.Execute(request);

We have implement Mautic REST API for perform basic operation.We wrote code for Create New Lead as below .We also got response 201 that stated that Lead is created but when i show in account there are no such new leads are created as I passed as parameter.Please suggetst.

       var baseUrl = new Uri(baseurl);
        var client = new RestClient(baseUrl)
        {
            Authenticator = OAuth1Authenticator.ForRequestToken(consumerKey, consumerSecret)
        };
        var request = new RestRequest("api/leads/new", Method.POST);
        client.Authenticator = OAuth1Authenticator.ForProtectedResource(consumerKey, consumerSecret, oauthToken,
            oauthTokenSecret);
        request.AddHeader("owner", "1");
        request.AddHeader("email", "ntest@test.com");
        request.AddHeader("lastname", "ntest");
        request.AddHeader("firstname", "ntest");

        // Expected Response Code: 201 for Successfully Lead Creation.
        var response = client.Execute(request);