We have a API that will return list of json items in an array in the below format:
[
{…},
{…}
]
So, when the items have been more than 100, it will return 100 items in one response and provide “nextPage” in the headers.
When it has less than 100 items, it won’t provide “nextPage” headers.
As per the API behaviour, I have the below httprequestbuilder and scenario builder:
val getActivationsOfMemberByFields: HttpRequestBuilder = getActivationOfMember("member_GetActivationsOfMemberByFields","?fields=full")
.check(header("nextPage").optional.saveAs("fieldNextPage"))
val getActivationsOfMemberByFieldsAndNextPage: HttpRequestBuilder = getActivationOfMember("member_GetActivationsOfMemberByFieldsAndNextPage","?fields=full&lastEvaluatedKey=${fieldNextPage}")
.check(header("nextPage").optional.saveAs("fieldNextPage"))
You’re right about the current behavior. .optional does not remove the previously saved value.
(TBH I’m not sure if it is the desired behavior, but I can imagine of use cases for that too)
Anyway, you can empty the value in the beginning of your loop.
Hi @GeMi, understood but in my code snippet I haven’t written the empty session after set the value for “fieldNextPage”. I am returning session.set(“fieldNextPage”, null) if “fieldNextPage” is found empty. So that set won’t discarded. Is that correct?
Hi @sbrevet , empty the value will impact in calling HTTP request “getActivationsOfMemberByFieldsAndNextPage” as we are passing the session value of “fieldNextPage” in queryparams.