Mulesoft & Google Drive integration

Mulesoft & Google Drive integration

About Google Drive connector

Google Drive is a file storage and synchronization service created by Google. It allows users to store files in the cloud, share files, and edit documents, spreadsheets, and presentations with collaborators.

The Anypoint connector for Google Drive enables you to simplify repetitive tasks by automating how you convert, sync and share folders and files across all of your cloud storage services. Now you can automate file processing, transfers and sharing, ranging from very simple tasks to the most complex and challenging workflows.

Associated Use Cases

Automate common business operations by integrating Google Drive with other business applications such as CRM, ERP, DocuSign, and so on. Possibilities include:

  • Backup and archive critical data?- Leverage the Google Drive connector to seamless integrate with your CRM like Salesforce, your ERP like SAP, EDI, and fulfillment systems, to archive necessary data.
  • Enable efficient Sales processes?- Enable two-way, real-time synchronization between your CRM like Salesforce and Google Drive to ensure that any changes made to a file can be reflected to both the platforms.
  • Automate pre-built ITSM workflows?- Boost productivity for your IT teams by connecting ServiceNow and Google Drive to automate your tickets, user management, and IT operations.
  • Increase productivity?- Connect your workplace productivity apps such as Microsoft Teams or Slack to Google Drive to update documents, add comments to documents, and share files without switching context.

url : https://docs.mulesoft.com/google-drive-connector/1.0/


Prerequisites

  • Google Account
  • Mulesoft Anypoint Account
  • Credentials to access Google Drive (Follow this video to create the credentials you need https://youtu.be/eD1P7v1XgaE?t=73)


Scenario

In this scenario we will see how to configure and use Mulesoft's Google Drive connector to upload and create a file in Google Drive.


Anypoint Studio

This is the connector that you need to include in your project:

Non è stato fornito nessun testo alternativo per questa immagine

And this is the project:

Non è stato fornito nessun testo alternativo per questa immagine

First of all,there is a Listener /gdrive/{op}/{type} that is our endpoint.

Then a check is performed on the uri paramer 'op':

- if it is 'upload', then the flow continues to create and upload the file to Google Drive

- if it is 'delete', then it will follow the steps to delete the file from Google Drive.

- in other cases it will do nothing.


UPLOAD case:

it is important to pass in the body of the request the content of the information that will then be written into the file.

For example:

<? xml version = "1.0"?

<Item PartNumber = "872-AA">

????<ProductName> Lawnmower </ProductName>

????<Quantity> 1 </Quantity>

????<USPrice> 148.95 </USPrice>

????<Comment> Confirm this is electric </Comment>

</Item>>        

the file format is specified in the uri parameter 'type'.

Example: type = ' xml' and it will be transformed in 'application/xml' by the Transform Message component.

And Response is:

Postman Request example:

Non è stato fornito nessun testo alternativo per questa immagine

Postman Response example:

Non è stato fornito nessun testo alternativo per questa immagine


DELETE case:

here in the body of the request you pass the id of the file you want to delete from Google Drive.

For example:


{
"fileID": "1eyQLniqcW88S_mhaP4CbFraHruufcgHv"
}        

Postman Request example:

Non è stato fornito nessun testo alternativo per questa immagine

Postman Response example:

Non è stato fornito nessun testo alternativo per questa immagine


Google Drive

Google Drive before upload:

Non è stato fornito nessun testo alternativo per questa immagine

Google Drive after upload:

Non è stato fornito nessun testo alternativo per questa immagine

Please,notify that the 'Untitled' name for file just uploaded depends not on Mulesoft but on the Google Drive API (https://developers.google.com/drive/api/guides/create-file).

When creating a file, these are the properties associated with it:

The file is given a kind of drive.file, an id, a name of "Untitled," and a mimeType of application / octet-stream


Documents

project (jar) :

https://drive.google.com/file/d/1bDSM3mHr25Yb569VXyPmAjaYtQYlMxsC/view?usp=sharing

Postman collection:

https://drive.google.com/file/d/1_7zoaOmzxOZj-S9alDr00AQmQG3tJ1i0/view?usp=sharing

要查看或添加评论,请登录

Francesco Suraci的更多文章

社区洞察