Reputation: 1
I am trying to execute azure table storage through APIM inbound policy. I am sending request through set-backend-service base-url. But I am not able to access the response from the backend URL and modify it according to the requirement.
I am using the below Script to get the response and I am trying to form my own JSON structure. But apart from xml-to-json I am not able to do anything.
<policies>
<inbound>
<base />
<cache-lookup vary-by-developer="false" vary-by-developer-groups="false" downstream-caching-type="none">
<vary-by-header>Accept</vary-by-header>
<vary-by-header>Accept-Charset</vary-by-header>
</cache-lookup>
<set-variable name="SASToken" value="@("sas key")" />
<set-variable name="TableStorageURL" value="@{string sastoken = context.Variables.GetValueOrDefault<string>("SASToken");return String.Format("https://storagedev.table.core.windows.net/data()?{0}", sastoken);}" />
<set-backend-service base-url="@($"{context.Variables.GetValueOrDefault("TableStorageURL")}")" />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
<xml-to-json kind="direct" apply="always" consider-accept-header="false" />
<cache-store duration="1000" cache-response="true" />
</outbound>
<on-error>
<base />
</on-error>
Upvotes: 0
Views: 540
Reputation: 6647
You can use the set-body
policy in the outbound
scope to fetch the response from your backend and change as per your needs.
You could even skip the xml-to-json
policy.
Also, consider using liquid templates which further simply how you transform your response.
Upvotes: 0