Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApiNodeList.nextPage requests one extra page when there's no more results #309

Closed
pawel-dabro opened this issue Sep 21, 2020 · 2 comments · May be fixed by #310
Closed

ApiNodeList.nextPage requests one extra page when there's no more results #309

pawel-dabro opened this issue Sep 21, 2020 · 2 comments · May be fixed by #310
Labels

Comments

@pawel-dabro
Copy link

Which SDK version are you using?

v. 7

What's the issue?

ApiNodeList.nextPage requests one additional page even when it's at the last page of results currently.
Documentation in https://developers.facebook.com/docs/graph-api/using-graph-api/#paging states:

Stop paging when the next link no longer appears.

However, in that case ApiNodeList.nextPage falls back to cursor-based paging mechanism and only stops after retrieving an additional empty page with no cursor information.

Steps/Sample code to reproduce the issue

Use any graph edge that returns ApiNodeList like campaigns, that returns one or more pages of data

Observed Results:

  • What happened? This could be a description, log output, etc.

For N pages of data, there is N+1 requests beign made. One final request is made when there is no next link, which results in a response with empty data array and no paging section. Only after that paging stops, even though it is apparent from the lack of next page in Nth response that N+1th request is not necessary.

Nth request

2020-09-21 13:06:33.743 ========Start of API Call========
2020-09-21 13:06:33.743 Request:
2020-09-21 13:06:33.743 GET: https://graph.facebook.com/v7.0/act_.../campaigns?acce
ss_token=...&fields=id%2Cname&limit=25&after=QVFIUkhyNWtiM1JJLTk5WEhRaWZAFc0F...&appsecret_proof=...
2020-09-21 13:06:33.831 Response:
2020-09-21 13:06:33.831 {"data":[
<LAST PAGE OF DATA RETURNED HERE>
],"paging":{"cursors":{"before":"QVFIUkVES3hiV0tyUjQ...","after":"QVFIUlJReDdpSDlOcHlGeUYzemhqNDRsYV..."},
"previous":"https:\/\/graph.facebook.com\/v7.0\/act_...\/campaigns?access_token=...&fields=id\u00252Cname&limit=25&before=QVFIUkVES3hi..."}}
2020-09-21 13:06:33.831 ========End of API Call========

N+1th request

2020-09-21 13:06:33.836 ========Start of API Call========
2020-09-21 13:06:33.837 Request:
2020-09-21 13:06:33.837 GET: https://graph.facebook.com/v7.0/act_.../campaigns?acce
ss_token=...&appsecret_proof=...&after=QVFIUlJReDdpSDlOcHlGeUYzemhqNDRsYV...&fields=id%2Cname
2020-09-21 13:06:33.887 Response:
2020-09-21 13:06:33.887 {"data":[]}
2020-09-21 13:06:33.887 ========End of API Call========

Expected Results:

  • What did you expect to happen?

ApiNodeList.nextPage should not make the extra (N+1th) request for empty page when it knows from its current state that there was no more data.

@stale
Copy link

stale bot commented Dec 25, 2020

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale label Dec 25, 2020
@stale
Copy link

stale bot commented Jun 26, 2021

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Jun 26, 2021
Adam-Jamka pushed a commit to codewise/facebook-java-business-sdk that referenced this issue Mar 31, 2023
apiechowicz pushed a commit to codewise/facebook-java-business-sdk that referenced this issue Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant