write a CSV file to an external server

Hi Team,

 

We need to write a CSV file to an external server every time an API is called.

please advise the feasibility and how can we achieve this. 

1 3 165
3 REPLIES 3

Using the ServiceCallout policy in your API Proxy, you can send out a CSV . 

If you need to send out a CSV for every request for every proxy, then I suggest embedding  that ServiceCallout into a Shared Flow, and then attaching that SharedFlow to a FlowHook, so that you don't  have to configure the same policy/step for each proxy in your environment.  (FlowHooks give you the ability to "automatically attach policies" for each environment) 

Thanks @dchiesa1  for the response

Only for a specific proxy we need to do that. So we will use a Service Call out policy.

https://docs.apigee.com/api-platform/reference/policies/service-callout-policy

As per the above documentations, we need to call and end point . But in our case we just need to place a CSV file in an external server. Can this be still done without an API from back end exposed? Appreciate if you can give a small Pseudocode (or direction ) on how to do that.  


@giri_apigee wrote:

Can this be still done without an API from back end exposed?


Hi Giri

Oh I see. I had assumed that the remote server, the one accepting inbound CSVs, had an HTTP listener.

Apigee in general is an HTTP reverse proxy.  ServiceCallout is just one of the steps you can add to an API proxy in Apigee, and yes, that ServiceCallout step needs to connect to an HTTP endpoint.  If you have a fileserver, accessible only via SSH or FTP, then .... ServiceCallout is not going to be able to connect to it. 

There is no good way to directly connect to a fileserver from within an Apigee API proxy. 

I can suggest a couple options.

  1. if you are comfortable writing and managing your own custom code.... write a bit of custom logic, that listens on an HTTP endpoint and connects to the server via whatever protocol the server supports (SSH or otherwise).  That logic will not run "in Apigee".  It will need to be hosted in some place that is  adjacent to Apigee.   It could run on the server itself, or it could run in some other place that connects to the server, like in CloudRun.  That would  allow you to use ServiceCallout to send the data you wish to send.  If you are comfortable with GRPC, and prefer to use it, you could do the same thing - write some custom logic -  except for GRPC you will want to use ExternalCallout in place of ServiceCallout.  
  2. If you would prefer to NOT write and manage more custom code.... you might want to consider Google Cloud Application Integration.  App Integration is designed specifically to solve for this connectivity-and-processing problem. In includes a variety of connectors, including FTP and SFTP.  You can visually design an integration that listens on an HTTP endpoint, and then Writes to an FTP or SFTP endpoint.  So you could use ServiceCallout to call into App Integration, then App Integration would write your data into the eventual target. 

 

If this one CSV writing challenge was the ONLY integration-like problem you were facing, I might take the custom-logic option. But if you have other connectivity and integration challenges, then App Integration might be a nice solution. 

Does this help?