Facebook-CSharp-Ads-SDK icon indicating copy to clipboard operation
Facebook-CSharp-Ads-SDK copied to clipboard

How to use paging?

Open simeyla opened this issue 6 years ago • 2 comments

How am I supposed to do paging when the response returns back paging element?

I can take the URL and run it but how to do that within your API?

simeyla avatar Mar 07 '18 02:03 simeyla

This was the best I came up with. Wish it was 'built in' in some fashion.

   if (campaignInsights.paging != null && campaignInsights.paging.next != null)
   {
       var url = new Uri(campaignInsights.paging.next.ToString()).PathAndQuery;
       var urlWithoutAPIVersion = url.Substring(url.IndexOf("/", 1));  // skip API version in URL

       campaignInsights = JObject.Parse(Api.Client.Get(urlWithoutAPIVersion).ToString());
   }

This is where campaignInsights is the response from GetInsights() where paging was returned.

simeyla avatar Mar 07 '18 04:03 simeyla

As far as I know there currently isn't support for this in the SDK yet, I'll have to see how the official API does it and see if I can implement it in the next release :)

Paradoxis avatar Mar 07 '18 08:03 Paradoxis