Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have 1467 locations. I want to get them using this line in c#:
C#
var client = new RestSharp.RestClient("https://mybusiness.googleapis.com/v4/accounts/103890250566243670362/locations/");
            client.Timeout = -1;
            var request1 = new RestRequest(Method.GET);
        { request1.RequestFormat = DataFormat.Json;};
             request1.AddHeader("Authorization", "Bearer "+ accesstoken);
            IRestResponse response1 = client.Execute(request1);


I got only 100 locations and nextpagetoken.
Is it possible to get more than 100 locations? How can i use the nextpagetoken in my c# code?

What I have tried:

I have 1467 locations. I want to get them using this line in c#:
C#
var client = new RestSharp.RestClient("https://mybusiness.googleapis.com/v4/accounts/103890250566243670362/locations/");
           client.Timeout = -1;
           var request1 = new RestRequest(Method.GET);
       { request1.RequestFormat = DataFormat.Json;};
            request1.AddHeader("Authorization", "Bearer "+ accesstoken);
           IRestResponse response1 = client.Execute(request1);


I got only 100 locations and nextpagetoken.
Is it possible to get more than 100 locations? How can i use the nextpagetoken in my c# code?
Posted
Updated 12-Nov-20 22:03pm
v2

1 solution

As you have seen, there is a hard limit on the number of locations that can be returned in one go. What you need to do is reissue your call using the page token like this:
C#
https://mybusiness.googleapis.com/v4/accounts/103890250566243670362/locations/?pageToken=<<page_token>>
This information is readily available in the documentation[^].
 
Share this answer
 
Comments
Maciej Los 13-Nov-20 4:31am    
5ed!
Pete O'Hanlon 13-Nov-20 4:43am    
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900