Search code examples
mulesoftmule-componentmule4mule-esbmule-connector

"status code 403" Error while creating file using Mule 4 google drive connector


I have to upload images to google drive through mule integration. I'm facing trouble with <google-drive:file-content> connector. Can someone help me or direct me a tutorial relates to it?

This is the error message while I tried to connect to the google drive

Message               : Request returned status code 403
Element               : imageuploaderFlow/processors/4 @ 
imageuploader:imageuploader.xml:39 (Create media file)
Element DSL           : <google-drive:create-media-file doc:name="Create media file" doc:id="hhhhhjhj" config-ref="Google_Drive_Connector_Config" contentType="application/octet-stream">
<google-drive:file-content><![CDATA[
#[payload.parts.image.content write "application/octet-stream"]
]]></google-drive:file-content>
</google-drive:create-media-file>
Error type            : GOOGLE-DRIVE:CLIENT_ERROR
FlowStack             : at imageuploaderFlow(imageuploaderFlow/processors/4 @ imageuploader:imageuploader.xml:39 (Create media file))

connector xml snippet

<google-drive:create-media-file doc:name="Create media file" doc:id="ac59e7fe-e615-fggh-9473-2we5cd73ecb7" config-ref="Google_Drive_Connector_Config" contentType="application/octet-stream">
            <google-drive:file-content ><![CDATA[#[payload.parts.image.content write "application/octet-stream"]]]></google-drive:file-content>
        </google-drive:create-media-file>

The version of the Google Drive connector is 1.0.1


Solution

  • Ensure that you have Enabled the Google Drive API in your project. Not enabling this also raises a 403 error. Also, mostly, Google API sends pretty clear message when you do something wrong. You can access the detailed HTTP response using error.errorMessage.payload and headers using error.errorMessage.attributes.headers