IgnoreUnresolvedVariable Property issue in ServiceCallout

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="SC">
    <DisplayName>SC</DisplayName>
    <Properties/>
    <Request clearPayload="false" variable="myRequest">
        <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
                <Copy source="request">
             <Headers>
            <Header name="Content-Type">{request.header.Content-Type}</Header>
            </Headers>
            <QueryParams/>
        </Copy>
    </Request>
    <Response>calloutResponse</Response>
    <HTTPTargetConnection>
        <URL>http://This is a dummy endpoint</URL>
    </HTTPTargetConnection>
</ServiceCallout>

We are trying to copy content-type header from the request .In a scenario where the header is not passed in the request we get the below error inspite of having <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>

Error:Unresolved variable : request.header.Content-Type

Is this a bug or an expected behavior?

@Dino-at-Google @Dino @Anil Sagar @ Google @Siddharth Barahalikar

0 9 404
9 REPLIES 9

I have used the same config and see no issue. Which Apigee version are you working on Cloud/On-prem?

We are using cloud version.

We're seeing the issue when there's no content-type passed in the request.

Not applicable

I tried the same in the cloud version. It works for me and I don't see any error. This looks like your target in the service-callout is expecting the content-type and the error is returning back from the target. Can you try changing the target to the one which doesn't expect any content type?

I verified and could tell the error was not from target. I validated the same on my trial org and this does indeed work fine. I'll have a ticket raised with Apigee on this for more info. Thank you.

can you try setting this through another assign message policy before the service-callout? You may find the error where happens.

Yes, I was able to move on by setting the content type in one of the JS policies just before the service callout.

does that resolve your issue?

Yes, that did solve the issue. But out of curiosity I reverted it to the original configuration and now I see it working too... Could it be that the changes were not synced across all MPs?

that could be some dirty read.