I have created an Azure API Management Service to connect to the API of Autotask.
Now I want to Query all tickets of a user, but I have to retrieve the tickets with pagination, as the tool I’m trying to make doesn’t Support as much Data at once.
The Autotask API when using pagination returns a “nextPageUrl” that u’ll have to call with the next API call.
Because of that, I have added a Query parameter to my API Mng and in the inbound policies i want to add a policy that changes the Backend URL to the given nextPageUrl if given. But if there is no URL given, it should just keep its current url.
So here I have the query parameter:
And this is the Part i added in the inbound policies:
<choose>
<when condition="@(!string.IsNullOrEmpty(context.Request.Url.Query.GetValueOrDefault('nextPageUrl', '')))">
<set-backend-service base-url="@{context.Request.Url.Query.GetValueOrDefault('nextPageUrl', '')}" />
</when>
<otherwise>
<set-backend-service base-url="https://webservices.autotask.net/ATServicesRest/v1.0/Tickets/query" />
</otherwise>
</choose>
i am no Pro in this matter, i tried to solve it with GPT and some research but this doesnt seem to work as i want it to. Does anybody know how i can properly write the policy?