home > support > API > Marketplace API > update booking
Update some of the information on an existing booking
Tour Operators can update quite a few fields, Marketplace Agents can only update agent_ref. Agents should request any further changes by using the Add note to booking API
Functionality to add or remove booking components is available via separate APIs.
Endpoint | /c/booking/update |
Formats | XML |
Example | URL: /c/booking/update.xml POST data:
|
Verb | POST |
PHP examples use the PHP Client Library with SimpleXML
object update_booking ( SimpleXmlElement $booking_data, int $channel )
// Set the channel ID
$channel = 3;
// Create a new SimpleXMLElement to hold the booking details
$booking = new SimpleXMLElement('<booking />');
// Must set the Booking ID on the XML, so TourCMS knows which to update
$booking->addChild('booking_id', '12345');
// Provide their special request information
$booking->addChild('customer_special_request', 'Please can we have a ground floor room');
// Call TourCMS API, updating the booking
$result = $tourcms->update_booking($booking, $channel);
// Check the result, will be "OK" if a booking was updated
switch ($result->error) {
case "OK":
// Print a success message
print "Thanks, your booking details have been updated.";
break;
case "NO DATA CHANGED":
// Nothing was changed, old data matched new data
print "Thanks, it looks like we have your request already!";
break;
default:
// Some other problem (could check error to see what)
print "Sorry, unable to update your booking details at this time.";
break;
}
Thanks, your booking details have been updated.
C# examples use the .Net Client Library
XmlDocument UpdateBooking ( XmlDocument bookingData, int channelId )
// Set the ID for the channel this booking is made with
int channelId = 3;
// Create an XMLDocument to hold the booking details
XmlDocument bookingData = new XmlDocument();
// Create the XML Declaration, append it to XML document
XmlDeclaration dec = bookingData.CreateXmlDeclaration("1.0", null, null);
bookingData.AppendChild(dec);
// Create the root element, append it to the XML document
XmlElement root = bookingData.CreateElement("booking");
bookingData.AppendChild(root);
// Must set the Booking ID so TourCMS knows which booking to update
XmlElement bookingId = bookingData.CreateElement("booking_id");
bookingId.InnerText = "12345";
root.AppendChild(bookingId);
// Now set any details that need updating
// Here we'll update the "Special request"
XmlElement req = bookingData.CreateElement("customer_special_request");
req.InnerText = "Please can we have a ground floor room";
root.AppendChild(req);
// Send the data to the TourCMS API, updating the Booking
XmlDocument doc = myTourCMS.UpdateBooking(bookingData, channelId);
// Check the status
// Will be "OK" if the booking was updated
// "NO DATA CHANGED" if the new data matched the old, etc
string status = doc.SelectSingleNode("//error").InnerText;
Console.WriteLine(status);
OK
VB examples use the .Net Client Library
XmlDocument UpdateBooking ( XmlDocument bookingData, Integer channelId )
' Set the ID for the channel this booking is made with
Dim channelId As Integer = 3
' Create an XMLDocument to hold the booking details
Dim bookingData As XmlDocument = new XmlDocument()
' Create the XML Declaration, append it to XML document
Dim dec As XmlDeclaration = bookingData.CreateXmlDeclaration("1.0", null, null)
bookingData.AppendChild(dec)
' Create the root element, append it to the XML document
Dim root As XmlElement = bookingData.CreateElement("booking")
bookingData.AppendChild(root)
' Must set the Booking ID so TourCMS knows which booking to update
Dim bookingId As XmlElement = bookingData.CreateElement("booking_id")
bookingId.InnerText = "12345"
root.AppendChild(bookingId)
' Now set any details that need updating
' Here we'll update the "Special request"
Dim req As XmlElement = bookingData.CreateElement("customer_special_request")
req.InnerText = "Please can we have a ground floor room"
root.AppendChild(req)
' Send the data to the TourCMS API, updating the Booking
Dim doc As XmlDocument = myTourCMS.UpdateBooking(bookingData, channelId)
' Check the status
' Will be "OK" if the booking was updated
' "NO DATA CHANGED" if the new data matched the old, etc
Dim status As String = doc.SelectSingleNode("//error").InnerText
Console.WriteLine(status)
OK
NodeJS examples use the NodeJS Wrapper
// This example sets the Customer Special Request field on the booking
TourCMS.updateBooking({
channelId: 3930,
booking: {
booking_id: 1234,
customer_special_request: "Please can we have a ground floor room"
},
callback: function(response) {
console.log(response.error);
}
});
OK
Looking for sample code in a different language? TourCMS and community provided API libraries
Implementing yourself? Check the REST info for this endpoint.
Enter your TourCMS API credentials below to call the Update Booking endpoint.
Take care, submitting this form will modify live data!
There are no querystring parameters.
The following fields can be posted as XML when calling the API, the booking_id is the only required field.
Any fields not present in the XML will not be updated, to clear a field you will need to add it to the XML but leave it's contents blank.
XML Node | Notes | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
booking |
The root XML element, can contain any of the following child nodes.
|
XML Node | Notes |
---|---|
request | Confirmation of the request that you sent |
error | Any error message returned, if there is no error this will just contain the text OK. If no data was updated (perhaps because the supplied data was the same as the existing data this will contain the text NO DATA CHANGED, you may wish to code for this and handle the same as an OK. |
booking |
If the booking was found there will be a booking node containing the following child nodes.
|