1 Reply Latest reply on Jun 23, 2019 5:37 AM by sk84

    REST API pagination problem

    shaharsib Novice

      Hi,

      Im using this REST command to get a list of all vcd users:

      curl -i -k -H "Accept:application/*+xml;version=31.0" -H "x-vcloud-authorization:f9c49bfdghkjkfgd4ebf4d7e2d89c17b" -X GET https://my-vcd/api/query?type=adminUser

      the problem is im getting only the first page.

       

      
      
      
      <QueryResultRecords xmlns="http://www.vmware.com/vcloud/v1.5" xmlname="adminUser" page="1" pageSize="25" total="43" href="https://my-vcd/api/query?type=adminUser&page=1&pageSize=25&format=records">
          <Link rel="nextPage" href="https://my-vcd/api/query?type=adminUser&page=2&pageSize=25&format=records" type="application/vnd.vmware.vcloud.query.records+xml"/>
          <Link rel="lastPage" href="https://my-vcd/api/query?type=adminUser&page=2&pageSize=25&format=records" type="application/vnd.vmware.vcloud.query.records+xml"/>
          <Link rel="alternate" href="https://my-vcd/api/query?type=adminUser&page=1&pageSize=25&format=references" type="application/vnd.vmware.vcloud.query.references+xml"/>
      

       

      this info is from the header.

      as you can see I have total of 43 users spread into 2 pages.

      I have read the REST manual and tried the following:

      curl -i -k -H "Accept:application/*+xml;version=31.0" -H "x-vcloud-authorization:f9c49bfdghkjkfgd4ebf4d7e2d89c17b" -X GET https://my-vcd/api/query?type=adminUser&page=2

      curl -i -k -H "Accept:application/*+xml;version=31.0" -H "x-vcloud-authorization:f9c49bfdghkjkfgd4ebf4d7e2d89c17b" -X GET https://my-vcd/api/query?type=adminUser&pageSize=128 (128 is the max entries number per page)

       

      but I keep getting the first page..

      I wish to get all 43 users in the same page.

      any help ?

        • 1. Re: REST API pagination problem
          sk84 Expert
          vExpert

          You must also put the request in quotation marks. The "&" character is otherwise interpreted by the shell (execute task in the background) and is no longer part of the request for curl. Therefore your request is always truncated at the "&" character and you always see the same page.

           

          So the right thing would be:

           

          curl -i -k -H "Accept:application/*+xml;version=31.0" -H "x-vcloud-authorization:f9c49bfdghkjkfgd4ebf4d7e2d89c17b" -X GET "https://my-vcd/api/query?type=adminUser&page=2"

          1 person found this helpful