Skip to main content
Best answer

Webhook POST Assistance for Document Upload

  • 20 August 2024
  • 6 replies
  • 23 views

Hi there,

 

I have a file URL that gets loaded to our CRM, Salesforce. I need to take that file URL, convert to Base64, then use a POST Webhook to upload the document to CompanyCam. I’ve accomplished the first two steps but need assistance with the POST Webhook.

 

The CompanyCam POST requirements are outlined here https://docs.companycam.com/reference/createprojectdocument.

 

For the Webhook step in Zapier, I’ve populated the following:

URL = https://api.companycam.com/v2/projects/{project_id}/documents

---- where project_id is mapped to the appropriate id from a previous step

Payload Type = json

Data = I need help with this field as it needs to look like the below but I need to insert the converted file from the Base64 step...I’m unsure how to insert the mapped field:

{   "document": {     "name": "test.pdf",     "attachment": "DOCUMENT FROM Base64 Step]”   } }

Wrap Request in Array: No

Unflatten: No

Headers:

Authorization -- Bearer hKEY]

X_COMPANYCAM_USER -- Xlogin id]

 

I keep running into error messages and I don’t know how to fix them. Can someone point me in the right direction? Should I be using the file field instead? I tried doing that but it didn’t work and based on the API documentation for CompanyCam, I am assuming it’s expecting the Data section I’ve noted above.

 

Thanks!

Hi @RooferA 

For us to have true context, post screenshots with how your Zap steps are outlined and configured in EDIT mode.


Sure, thanks for your help! See below -

 

Step 1 - trigger when url field is updated

 

Step 2 - convert URL to Base64

 

Step 3 - POST JSON to Update Document Attachment to CompanyCam

 


@RooferA 

Try using this Zap action: Webhooks - Custom Request

Method: POST

Body: use the JSON


Thanks Troy. I did try that but based on the articles I was reading online, I’d have to post more info than what’s required on the CompanyCam website; for instance Content-Type, Content-Length, Host, User-Agent etc.

 

I am unsure of what fields are required and how to populate them. For instance, I don’t know hot to get the content length of the Base64 file. Would you be able to assist?


@RooferA 

Link to the resource you are referencing about the added data points. (User-Agent, etc.)

 

Reference the CompanyCam API documentation for the required fields and values.

 

Headers: 4 are shown in the CURL request example.

 

Body: JSON to use

{
"document": {
"name": "xxx",
"attachment": "xxx"
}
}

 


It worked! Thank you so much for your help, Troy!!


Reply