File response from service callout produce blank files

Hi,

We have an external API that our Apigee should invoke after some elaboration in our proxy.
I have used a service callout in the request flow :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="SC-fileRetrieve">
    <DisplayName>SC-fileRetrieve</DisplayName>
    <Response>versionDataResponse</Response>
    <Request>
        <Set>
            <Verb>GET</Verb>
            <Headers>
                <Header name="Authorization">Bearer {accessToken}</Header>
            </Headers>
        </Set>
    </Request>
    <HTTPTargetConnection>
        <URL>https://{var_sfdc_url}/{versionData}</URL>
    </HTTPTargetConnection>
</ServiceCallout>
And in the response flow I am using an Assign Message to put the Service Callout in the response of the proxy :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-fileTestResponse">
    <Set>
        <Payload contentType="application/octetstream">{versionDataResponse.content}</Payload>
    </Set>
    <AssignTo createNew="false" transport="http" type="response"/>
</AssignMessage><br><br>

But the file retrieved from the response of my flow is blank.
If i make the same exact request directly to https://{var_sfdc_url}/{versionData} the result is the correct pdf file.

Am I doing something wrong / missing something ?

Solved Solved
0 12 1,088
1 ACCEPTED SOLUTION

12 REPLIES 12

Not applicable

hi,

The service callout response is stored in versionDataResponse and you need to set the response.content to that.

Don't set payload in assign message policy. Just set the response.content to versionDataResponse using assign message or javascript in the response flow

Hi Priyadarshi,
thanks for answering.
I've modified my AssignMessagePolicy to this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-fileTestResponse">
    <AssignVariable>
        <Name>response.content</Name>
        <Value>versionDataResponse</Value>
    </AssignVariable>
    <!-- <Set>
        
        <Payload contentType="application/octetstream">{versionDataResponse.content}</Payload>
    </Set>-->
    <AssignTo createNew="false" transport="http" type="response"/>
</AssignMessage>
	

but still the pdf resulting is blank and differ from the response of the direct request to the external api made in postman:

10719-difference.png

File pdf downloaded by my proxy :

10721-filefrommyproxy.png

File pdf downloaded by the direct request:

10720-filefromdirecthttprequestexternalapi.png

It seems that the bytecode of the file is somewhat corrupted or something like that.

Not applicable

This will be different. Just try as below.

<AssignVariable>

<Name>response.content</Name>

<Ref>versionDataResponse</Ref>

</AssignVariable>

Try like this. Don't add payload tags.


I've tried to change the assignMessage in post flow as you described but now i'm not receiving a bytecode anymore, instead a reference to the inmemory variable of apigee:

10723-requestresponse.png

Also the headers are not correct, you can see now the content-type is application/json and not application/octetstream:

10724-requestheader.png

The desired outcome is to have entirely the servicecallout response as the response of my flow.

are you able to get the response as expected in the "versionDataResponse" variable in trace?

if yes then see the content type is not matching. you need to set the content type same as you are getting the service callout response.

Hi,

I think the problem is linked with a similar problem with the extension Callout:

please review this answer by @dino-at-google

https://community.apigee.com/answers/89630/view.html

Can't access the link. Did you find a solution for this?

Is this issue resolved ? Even I am facing the same issue.

 
 

My response from February 1st, 2022, is still valid. Have you read it?  Tried what I suggested there?

I am facing the same issue as well. Is it resolved ? @aldoloria

My response from February 1st, 2022, is still valid. Have you read it?  Tried what I suggested there? And your  results?