In IIS version 10, I installed Rewrite Module and I am trying with the above XMLs the following action.
I want to set "201 or 202 Active" status instead of default 200 OK to all successful requests (only when my api should return 200 OK).
When it matches 200 should return 201 or 202 (it works fine), but it returns 202 to all of the requests i send via postman, even when it should return 400.
I am trying to find how this will work but I keep getting 202 for all requests.
How can I write/configure it in IIS without changing my api ?
<rule name="SetStatusTo202ForSuccess" enabled="false" patternSyntax="Wildcard" stopProcessing="true">
<match url="item-base-data" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{RESPONSE_STATUS}" pattern="200" />
</conditions>
<action type="CustomResponse" statusCode="202" subStatusCode="200" statusReason="Accepted" statusDescription="." />
<serverVariables>
<set name="RESPONSE_STATUS" value="202" />
</serverVariables>
</rule>
I tried, inbound rule and outbound rules.
In outbound rules I tried this :
<rule name="ChangeStatusCode" preCondition="Is200StatusCode" patternSyntax="Wildcard">
<match serverVariable="{RESPONSE_STATUS}" pattern="200" />
<action type="Rewrite" value="202" />
</rule>
<preConditions>
<preCondition name="Is200StatusCode">
<add input="{RESPONSE_STATUS}" pattern="200" />
</preCondition>
</preConditions>
Thank you in advance.