Referring to my blog on Azure API Management Troubleshooting Series, this is the first scenario of the lab. Please make sure you have followed the lab setup instructions as per this, to recreate the problem.
The API ‘Blank API’ consists of two operations ‘GetHeaders’ and ‘GetMyIp’. GetMyIp returns the value of X-FORWARDED-FOR header value and GetHeaders returns all the request header values. GetMyIp returns expected output but suddenly GetHeaders started returning a blank response (no response body).
Expected output of GetHeaders API should be something like below:
"Accept-Encoding": "gzip, deflate",
"Cookie": "_gauges_unique_day=1; _gauges_unique_month=1; _gauges_unique_year=1; _gauges_unique=1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0"
To debug these kind of issues, the best approach is collect APIM inspector trace to inspect request processing inside APIM pipeline.
- If you look into the trace you would notice that forward-request policy is missing.
- The forward-request policy forwards the incoming request to the backend service specified in the request context.
- Removing this policy results in the request not being forwarded to the backend service and the policies in the outbound section are evaluated immediately upon the successful completion of the policies in the inbound section.
- Hence if you check the
section of the ‘GetHeaders’ operation under ‘Blank-API’ you would notice that forward-request policy is removed.
- Add the forward-request policy in the backend section or add
element so that it inherits forward-request policy from the parent level (i.e. from the API level), which should resolve the problem.
Read about the forward-request Policy to know more about it.
Happy learning !
This post first appeared on MSDN Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The MSDN Blogs., please read the originial post: here