cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5421
Views
0
Helpful
2
Replies

"Bookings Put" xAPI Command in a macro

julien.laffitte
Level 1
Level 1

Hello,

In the CE 9.13 Application Programming Interface (API) Reference Guide the xapi commands list was updated with the "xCommand Bookings Put" command to push meetings to the endpoint:

2020-09-09_101842.png

using this JSON format, we are trying to implement this command in a macro so that the terminal is able to push himself a booking(s) list:

const xapi = require('xapi');

//when the jsxapi connection is ready...
xapi.on('ready', () => {
  console.log('connection successful');
  pushBookingsList(console.log);
});

// Push the bookings list
function pushBookingsList(cb) {
  
  // JSON Bookings Data to be sent
  var payload =  {
  Bookings: [
      {
        Id: "1",
        Number: "123456789@my.domain",
        Organizer: {
          Name: "Organizer Name"
        },
        Protocol: "SIP",
        Time: {
          Duration: 60,
          EndTimeBuffer: 50,
          StartTime: "2020-09-10T14:00Z"
        },
        Title: "Push OBTP through Macro"
      }
    ]
  };
  xapi.command(
      'Bookings Put',{}, JSON.stringify(payload))
      .then((response) => {
        if ((response.StatusCode == 200) || (response.StatusCode == 201)) {
          console.log("Booking(s) Pushed Successfully to endpoint.")
          if (cb) cb(null, response.StatusCode)
          return
        }
              
        console.log("Booking(s) Push failed with status code: " + response.StatusCode)
        if (cb) cb("Booking(s) Push with status code: " + response.StatusCode, response.StatusCode)
      })
      .catch((err) => {
        console.log("Booking(s) Push failed with err: " + err.message)
        if (cb) cb("Could not Push the Booking(s) list to the endpoint.")
      })
  
}

However it does not work, we are getting a "Device not entitled" error when sending the command.

This feature is poorly documented and the error does not appear in any Cisco official document: would you have some additional information about this command and what is wrong in our code?

 

As a side note, the "xCommand Bookings List" works great:

const xapi = require('xapi');

//when the jsxapi connection is ready...
xapi.on('ready', () => {
  console.log('connection successful');
  getBookingsList();
});

// Get the bookings list
function getBookingsList() {
   
  try {
    var result = xapi.command('Bookings List', { Days: 10, Limit: 100 })
    // JSON Formatted Bookings Data
    .then((bookingsList) => { console.log(bookingsList)});
  }
  catch(err) {
    console.error(`cannot get bookings list.`);
    throw new Error("BOOKINGS_LIST_ERROR");
  }
}

Thanks for your help!

2 Replies 2

Ronald Garcia
Level 1
Level 1

Hello,

 

I have this problem too.

 

I had could not put the Xcommand Bookings Put.

 

Did you resolve it?

 

BR

Hello Ronald,

Actually we got an explanation from the TAC and unfortunately it seems that in our situation the "Device not entitled" error is the correct behavior (on-premise endpoints registered on our CUCM); below the answer from the engineer:

 

"This API is only available for cloud registered devices or WebeX Edge registered devices, and this is the error expected if you are not."

 

So you might be hitting the same issue here.

 

Best regards,

 

Julien