Create a campaign

S’abonner

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 );
    }
});
Cet article vous a-t-il été utile ?
Utilisateurs qui ont trouvé cela utile : 0 sur 0

Commentaires

0 commentaire

Vous devez vous connecter pour laisser un commentaire.