Créer une cible

As seen before, Basic Authentication header should be set to authenticate every call to the API. Please read this article for more details.

BEAR API being a REST one (look here for more details), we will have to use a POST request to create a marker.

In order to create a new marker you must first know the ID of the campaign which the marker will be added to. Learn how to create a new campaign here. To get a list of existing campaigns, you can call GET http://apidev.bear2b.com/campaigns

There are 2 options to provide actual image to be used as a marker - over URL or by selecting file from the local drive.


Creating marker from an URL (example is written in JavaScript with jQuery)

var user = 'user';

var password = 'test';

var auth = "Basic " + btoa(user + ":" + password); 

var urlApi = 'https://apidev.bear2b.com/markers';

// Users allowed to add markers to their own campaigns or to campaigns of their company

var campaignId = 649; // user's campaign (Your First Campaign)

// Note: you can get list of your campaings by calling GET http://apidev.bear2b.com/campaigns 

var params = {





   processData: true,

   type: 'POST',

   url: urlApi,

   headers: {"Authorization": auth},

   data: JSON.stringify(params),

   dataType: 'json',

   success: function(data){

       var marker = data[0];


       $('body').html('#'+marker.id + ' ' + marker.page_num);


   error: function(data){

       $('body').html( 'Marker has been created!' );

       $('body').html( data.responseJSON.error + ' ' + data.responseJSON.description );




Sending marker from file

<form action="http://user:test@apidev.bear2b.com/markers" method="POST" enctype="multipart/form-data">

   <p>campaign id:<input name="book_id" type="text" value="649"/></p>

   <p>marker:<input name="file" type="file" /></p>

   <p><button type="submit">Submit</button></p>



0 Commentaires

Veuillez vous connecter pour laisser un commentaire.