Create a campaign

Follow

As always, to authenticate a call Basic Authentication header should be set. See Authentication for details. As soon as BEAR API is REST one (details), to create a campaign we have to use POST request to campaigns.

Only users with admin role can create a campaign.

Code (working example here):

var user = 'admin';
var password = 'test';
var auth = "Basic " + btoa(user + ":" + password);
var urlApi = 'https://apidev.bear2b.com/campaigns';
var params = {name:'test'};
$.ajax({
    processData: true,
    type: 'POST',
    url: urlApi,
    headers: {"Authorization": auth},
    data: JSON.stringify(params),
    dataType: 'json',
    success: function(data){
        var campaign = data[0];
        $('body').html(campaign.id + ' ' + campaign.name);
    },
    error: function(data){
        $('body').html( data.responseJSON.error + ' ' + data.responseJSON.description );
    }
});

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.