0
votes

I am using set status code policy in which i will be returning the status code and corresponding status reason for it , The reason is fetched during runtime and in developer portal if i try to hit the api i was able to receive the staus code with the expected reason message but if i call from by hosted service i am getting only the status code and i am not getting the related reason message

This does not exist in all APIM instances which I have it's in particular instance alone

I am getting the status reason if I try from developer portal

Note: The message variable in status reason is fetched from named values during run time


Code:

        <when condition="@(!14==14))">
          <return-response>
            <set-status code="410" reason="@(context.Variables.GetValueOrDefault<string>("Message"))" />
            <set-header name="Cache-Control" exists-action="override">
               <value>max-age=0, no-cache, no-store, must-revalidate, proxy-revalidate</value>
            </set-header>
          </return-response>
        </when>

Postman Call: Reason is not received only code ref:yellow highlighted box enter image description here


Developer Console: Yellow Highlighted box shows both code and message enter image description here

1

1 Answers

0
votes

Since you are getting different behavior between different instances of APIM, it seems most likely that the problem is that the "Message" variable isn't set correctly on the instance where the reason value isn't getting returned.

I wasn't able to exactly replicate this. When using a known status code like 410 the APIM instances I tested all seemed to set "Gone" as the reason if none was specified. But with an unknown status code no reason was returned. I didn't see any difference in behavior between a new and old APIM instance.