I have a couple of Assign Message policies used to create a response for a targetless proxy. The first Assign Message creates the response payload as follows:
<DisplayName>Create Response with Expiration</DisplayName> <Properties/> <Remove> <Headers/> <QueryParams/> <FormParams/> </Remove> <Set> <StatusCode>201</StatusCode> <ReasonPhrase>Created</ReasonPhrase> <Payload contentType="application/json" variablePrefix="@" variableSuffix="#"> { [....] } </Payload> </Set> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="response"/>
The next fills in the Location header for the response:
<DisplayName>Add Location Header</DisplayName> <Properties/> <Add> <Headers> <Header name="Location">{request.path}/{profileId}</Header> </Headers> </Add> <Set> <StatusCode>201</StatusCode> <ReasonPhrase>Created</ReasonPhrase> </Set> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="response"/>
I need to set the status code for the response to 201, to indicate that the requested data has been created on the server, but the proxy continues to return 200 instead of the specified 201.
If I try createNew=true in the first Assign Message, the second Assign Message will fail as the request.path variable will be empty.
I have set StatusCode in the past without issue, but cannot see why this particular case fails even though I am setting it twice (originally, I set it only in the first Assign Message).