Hello @Raimondas Rimkus , based on this solution here. <rewrite-uri template="/" />
will override the operation URL and https://my.api.management.com/redirect-test/
will be mapped to https://petstore.swagger.io/
. Now if you do not do rewrite-uri
then https://my.api.management.com/redirect-test/this/part/is/not/found
will be mapped to https://petstore.swagger.io/this/part/is/not/found
. Now regarding the <redirect-content-urls />
will just replace the backend URI with APIM URI. Can you please confirm if you want to map https://my.api.management.com/redirect-test/
to https://petstore.swagger.io/
?
<redirect-content-urls /> produces invalid URL when used with <rewrite-uri />
Goal: response body contains full backend server URL that needs to be replaced with API management server URL. API URL and Operation URLs can't be changed. Operation contains rewrite-uri
policy to map API Management URL to root backend URL.
API management URL (obfuscated): https://my.api.management.com/
API URL: redirect-test
Operation URL: /this/part/is/not/found
Policy:
<policies>
<inbound>
<base />
<rewrite-uri template="/" />
<set-backend-service base-url="https://petstore.swagger.io/" />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
<redirect-content-urls />
</outbound>
<on-error>
<base />
</on-error>
</policies>
Request: https://my.api.management.com/redirect-test/this/part/is/not/found
Backend response contains: url: "https://petstore.swagger.io/v2/swagger.json"
API Management response contains: url: "https://my.api.management.com/redirect-test/v2/swagger.json"
Expected API Management response: url: "https://my.api.management.com/redirect-test/this/part/is/not/found/v2/swagger.json",
Content is properly replaced (operation URL included) if rewrite-uri
is not used.
2 answers
Sort by: Most helpful
-
ChaitanyaNaykodi-MSFT 26,101 Reputation points Microsoft Employee
2020-11-07T01:29:59.667+00:00 -
Raimondas Rimkus 1 Reputation point
2020-11-16T07:58:12.06+00:00 We need to use
rewrite-uri
to reformat the URL to the backend format, and we need to useredirect-content-urls
to mask all the backend URLs in the response body. As described in the first post, we need to maphttps://my.api.management.com/redirect-test/this/part/is/not/found/
tohttps://petstore.swagger.io/
in the inbound operation (where/redirect-test/
is API URL andthis/part/is/not/found/
is operation URL) and map it back in the outbound operation.They both work properly when not used together, but we need to use both policies in a single operation.