I am trying send data as formparam in service callout to hit the backend

I have some form param which i need to hit the backend .

My code is as follows

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout name="ServiceCallout-GeocodingRequest1">
    <DisplayName>Inline request message</DisplayName>
    <Request variable="authenticationRequest">
        <Set>
            <FormParams>
                <FormParam name="address">{request.formparam.postalcode}</FormParam>
                <FormParam name="region">{request.formparam.country}</FormParam>
            </FormParams>
        </Set>
    </Request>
    <Response>GeocodingResponse</Response>
    <Timeout>30000</Timeout>
    <HTTPTargetConnection>
        <URL>http://httpbin.org/get</URL>
    </HTTPTargetConnection>
</ServiceCallout>

Can anybody guide me?
It gives me error ..

unresolved variable type..
Solved Solved
0 3 634
1 ACCEPTED SOLUTION

@Vinod Mehta - Here is the working version of your service callout

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="ServiceCallout-GeocodingRequest1">
    <DisplayName>ServiceCallout-GeocodingRequest1</DisplayName>
    <Request variable="authenticationRequest">
        <Set>
            <FormParams>
                <FormParam name="address">{request.formparam.postalcode}</FormParam>
                <FormParam name="region">{request.formparam.country}</FormParam>
            </FormParams>
            <Verb>POST</Verb>
        </Set>
    </Request>
    <Response>GeocodingResponse</Response>
    <Timeout>30000</Timeout>
    <HTTPTargetConnection>
        <URL>http://httpbin.org/post</URL>
    </HTTPTargetConnection>
</ServiceCallout>

Ther target server accepts only POSTR requests where you are using GET which is the first issue in your proxy.

. also please use

<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>

as suggested by @Sujnana Rai for unresolved variables.

View solution in original post

3 REPLIES 3

Does incoming request contains postalcode and country form parameters? The error says it unable to resolve these parameters. Check if you are sending these form parameters in request.

If these parameters are optional then you can add following to service callout

<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>

@Vinod Mehta - Here is the working version of your service callout

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="ServiceCallout-GeocodingRequest1">
    <DisplayName>ServiceCallout-GeocodingRequest1</DisplayName>
    <Request variable="authenticationRequest">
        <Set>
            <FormParams>
                <FormParam name="address">{request.formparam.postalcode}</FormParam>
                <FormParam name="region">{request.formparam.country}</FormParam>
            </FormParams>
            <Verb>POST</Verb>
        </Set>
    </Request>
    <Response>GeocodingResponse</Response>
    <Timeout>30000</Timeout>
    <HTTPTargetConnection>
        <URL>http://httpbin.org/post</URL>
    </HTTPTargetConnection>
</ServiceCallout>

Ther target server accepts only POSTR requests where you are using GET which is the first issue in your proxy.

. also please use

<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>

as suggested by @Sujnana Rai for unresolved variables.

Let me know if you need sample proxy which i have created for you.