Image is not getting stored in apigee baas properly using Api Proxy call on edge

Not applicable

Hi All,

We are trying to upload image file fetched from salesforce to apigee baas with edge using service callout.

We are getting binary response from target and directly storing that response to baas as below:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<ServiceCallout async="false" continueOnError="false" enabled="true" name="sc_postimgtobaas">

<DisplayName>sc_postimgtobaas</DisplayName>

<Properties/>

<Request clearPayload="true" variable="myRequestx">

<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>

<Set> <Headers> <Header name="Content-Type">application/octet-stream</Header> </Headers> <Payload Content-Type="application/octet-stream">{response.content}</Payload> <Verb>POST</Verb>

</Set>

</Request>

<Response>calloutResponsex</Response>

<HTTPTargetConnection> <URL>https://api.usergrid.com/vchikane/sandbox/tests/{uuid}</URL> </HTTPTargetConnection>

</ServiceCallout>

with this service callout, files meta data is getting created in baas, but with content type as Application/Octet-Stream.entitycreatedbyapiproxycall.txt

The same request we are trying using Postman Rest client, it'w working properly.postman-call.jpg

entitycreatedbypostmancall.txt

I tried using Request method in javascript policy also using Service Callout Policy. I cac see that image using postman(send and download) by hitting the proxy which fetches image from salesforce. But when response of that service callout I try to store in BaaS then I am not able to fetch the Image from Baas, because it's not recognizing it I guess.

Attaching the sample proxy bundle which gets an Image from Google and stores it to BaaS, also trace logs for the same.salesforce-connectivity-rev7-2016-10-25.zip

trace-1477404914978.zip

0 3 422
3 REPLIES 3

sarthak
Participant V

@Siddhesh Can you please share the proxy bundle and a valid API call so that we can test?

Hi Sarthak,


Please find below attached proxy bundle and trace log.

salesforce-connectivity-rev7-2016-10-25.zip

trace-1477404914978.zip

When we are trying same in postman as shown below, its working properly:

postman-call.jpg

Also find different baas entities created by postman call and api proxy call:

entitycreatedbyapiproxycall.txt

entitycreatedbypostmancall.txt

Let me know if anything else is required.

Thanks in advance.

sarthak
Participant V

@Siddhesh I don't have a solution yet, but couple of quick thoughts:

So, this is the call using which you upload an asset to BaaS

curl -X POST -i -F name='clouds' -F file=@google-logo.jpg -F owner=sarthak -F path=abcd 'http://amer-apibaas-prod.apigee.net/appservices/<org>/<env>/<collection>/'

The two parameters of owner and path are not documented in docs page. I raised a jira for that. For now just put some value

This is what we need to replicate using policies.

I tried a couple of quick things and havn't been able to do this using service callout policy. The Content-Type being multipart/form-data maybe causing the issue.

I think a javascript policy maybe the easiest to persist the data in BaaS.

You can see some code samples of javascript for BaaS upload here: https://community.apigee.com/questions/31027/asset-upload-problem-js.html

Give it a shot and let me know what you find out. If I get some more time, I will play around a bit as well.