{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Developer Portal (Integrated) /
avatar image
0
Question by Aldo Loria · Jan 15 at 10:31 AM · 48 Views proxy configurationservice calloutassign message policyfile handling

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 ?

Comment
Add comment
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Close

2 Answers

  • Sort: 
avatar image
0

Answer by Priyadarshi Ajitav Jena · Jan 15 at 11:53 AM

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

Comment
Add comment Show 1 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Aldo Loria · Jan 15 at 12:22 PM 0
Link

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:

File pdf downloaded by my proxy :

File pdf downloaded by the direct request:

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

difference.png (4.7 kB)
filefrommyproxy.png (26.6 kB)
filefromdirecthttprequestexternalapi.png (48.5 kB)
avatar image
0

Answer by Priyadarshi Ajitav Jena · Jan 15 at 01:25 PM

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.


Comment
Add comment Show 2 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Aldo Loria · Jan 15 at 03:09 PM 0
Link

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:

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

The desired outcome is to have entirely the servicecallout response as the response of my flow.
requestresponse.png (16.0 kB)
requestheader.png (31.7 kB)
avatar image Priyadarshi Ajitav Jena Aldo Loria · Jan 15 at 04:17 PM 0
Link

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.

Follow this Question

Answers Answers and Comments

45 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges