Forum - Book a room via API

  • This topic has 5 replies, 2 voices, and was last updated 4 weeks, 1 day ago by Sebastien Leyreloup.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #65165
    Sebastien Leyreloup
    Participant

    Hello,
    I want to book a room via API in alma. My test works but I don’t see in the request xml the item_id and barcode attributes of the room.
    If i do the same operation directly in alma, i see theses 2 attributes…

    I use the API POST /almaws/v1/users/{user_id}/requests

    I provide the good user_id, mms_id and pid_item parameters…

    My body request paramater is like this :

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <user_request>
    <author>my_user_id</author>
    <request_type>BOOKING</request_type>
    <pickup_location>BU Richter</pickup_location>
    <pickup_location_type>LIBRARY</pickup_location_type>
    <pickup_location_library>MBUS</pickup_location_library>
    <material_type>ROOM</material_type>
    <comment>Test from API</comment>
    <item_id>23319779020004231</item_id>
    <barcode>0MPS0307164</barcode>
    <request_date>2020-02-18T14:07:00Z</request_date>
    <booking_start_date>2020-02-19T11:00:00Z</booking_start_date>
    <booking_end_date>2020-02-19T11:59:00Z</booking_end_date>
    </user_request>

    I don’t understand whats’s wrong ? Thanks.

    #65166
    Sebastien Leyreloup
    Participant

    I also used the API POST /almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items/{item_pid}/requests
    and i have the same result : no item_id and barcode attributes in my xml request.

    #65167
    Tami Fuches
    Moderator

    Hi,
    Are you sending the mms_id and item_pid as parameters?
    They should be sent as parameters, not as part of the body.
    See documentation of the API: https://developers.exlibrisgroup.com/alma/apis/docs/users/UE9TVCAvYWxtYXdzL3YxL3VzZXJzL3t1c2VyX2lkfS9yZXF1ZXN0cw==/

    Tamar
    Alma API team

    #65169
    Sebastien Leyreloup
    Participant

    Hi,
    Yes of course, i send the mms_id and item_pid as parameter, not as part of the body.

    When i use the API Console from Ex Libris Developer Network with my token, i have the same problem.

    My test code in PHP is like that :

    $token=”xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”;
    $user_id=”xxxxxxxxxxxx”;

    $selected_mms_id=”9928507168404231″;
    $selected_item_id=”23338708750004231″;

    date_default_timezone_set(‘Europe/Paris’);

    $start = gmdate(‘Y-m-d\TH:i:s\Z’, strtotime(“2020-02-17 08:30:00”));
    $stop = gmdate(‘Y-m-d\TH:i:s\Z’, strtotime(“2020-02-17 10:30:00″));

    $request_date = gmdate(‘Y-m-d\TH:i:s\Z’);

    // Store XML Request object in Variable for passing to curl
    $request_xml = ‘<?xml version=”1.0″ encoding=”UTF-8”?>
    <user_request>
    <request_type>BOOKING</request_type>
    <pickup_location>BU Sciences</pickup_location>
    <pickup_location_type>LIBRARY</pickup_location_type>
    <pickup_location_library>MBUS</pickup_location_library>
    <material_type>ROOM</material_type>
    <comment>#’.$selected_item_id.’#</comment>
    <request_date>’.$request_date.'</request_date>
    <booking_start_date>’.$start.'</booking_start_date>
    <booking_end_date>’.$stop.'</booking_end_date>
    </user_request>’;

    $ch = curl_init();
    $url = ‘https://api-eu.hosted.exlibrisgroup.com/almaws/v1/users/&#8217;.$user_id.’/requests’;
    $queryParams = ‘?’ . urlencode(‘user_id_type’) . ‘=’ . urlencode(‘all_unique’) . ‘&’ . urlencode(‘mmsid’) . ‘=’ . $selected_mms_id . ‘&’ . urlencode(‘item_pid’) . ‘=’ . $selected_item_id . ‘&’ . urlencode(‘lang’). ‘=’. urlencode(‘fr’). ‘&’ . urlencode(‘apikey’) . ‘=’ . urlencode($token);
    curl_setopt($ch, CURLOPT_URL, $url . $queryParams);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ‘POST’);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $request_xml);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/xml’));
    $response = curl_exec($ch);
    curl_close($ch);

    print_r($request_xml);

    print_r($response);

    I test to add <item_id></item_id> and <barcode></barcode> in the xml user_request body parameter but that do nothing else…
    Thanks for your help.

    • This reply was modified 1 month, 2 weeks ago by Sebastien Leyreloup.
    #65398
    Sebastien Leyreloup
    Participant

    Hi,
    I have do more tests today and now, even if i make a booking via Alma, i do not retrieve the bar-code in the xml request nor in alma.
    I have now the same result when i do a booking from alma and from API.

    So i think there are modification about this in the March release update of alma…

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.