Extraction of Authorization request header and assignment to variable during ServiceCallout Policy execution

I am receiving the following error during the process:

{"fault":{"faultstring":"Unresolved variable : oauthtoken","detail":{"errorcode":"entities.UnresolvedVariable"}}}

My Service Policy looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout continueOnError="false" enabled="true" name="Introspect-Token">
    <DisplayName>Introspect-Token</DisplayName>
    <Properties/>
    <Request clearPayload="true" variable="myRequest">
        <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
        <ExtractVariables>
            <Header name="Authorization">
                <Pattern ignoreCase="false">Bearer {oauthtoken}</Pattern>
            </Header>
        </ExtractVariables>
        <Set>
            <Headers>
                <Header name="Authorization">Basic base64encodedclientidandsecret </Header>
                <Header name="ContentType">application/x-www-form-urlencoded</Header>
                <Header name="Accept">application/json</Header>
            </Headers>
            <FormParams>
                <FormParam name="token">{oauthtoken}</FormParam>
                <FormParam name="token_type">access_token</FormParam>
            </FormParams>
            <Verb>POST</Verb>
        </Set>
    </Request>
    <Response>calloutResponse</Response>
    <HTTPTargetConnection>
        <Properties/>
        <URL>https://myoauthseverurl/introspect</URL>
    </HTTPTargetConnection>
</ServiceCallout>

I appreciate the troublshooting help!

Solved Solved
0 2 660
1 ACCEPTED SOLUTION

The error is telling you that the variable “OAuthtoken” is undefined.

You are referring to it in.... the Request element.

But...

You have other problems.

The ServiceCallout is a distinct policy from ExtractVariables. It looks to me that you have embedded the configuration for the latter policy within the former. That won’t work.


I suggest that you consult the documentation for the Apigee policies before continuing your efforts.

View solution in original post

2 REPLIES 2

The error is telling you that the variable “OAuthtoken” is undefined.

You are referring to it in.... the Request element.

But...

You have other problems.

The ServiceCallout is a distinct policy from ExtractVariables. It looks to me that you have embedded the configuration for the latter policy within the former. That won’t work.


I suggest that you consult the documentation for the Apigee policies before continuing your efforts.

Thanks, I did not realize that policies could not be embedded inside another policy. Got it now....