Reputation: 753
I am creating a zap in Zapier that searches for a particular client and then finds their folder in Google Drive. It then takes a PDF document from the Google Drive folder and uploads to HelloSign to send to the client. I am using a Code by Zapier step to pull the PDF from Google Drive and upload to HelloSign.
The code I have in the Code by Zapier step works on my local machine, but when I attempt to run it in Zapier I get "OSError: [Errno 30] Read-only file system" for the document I'm trying to create so I can read the PDF for the line that has "with open('Test.pdf','wb') as f". From reading another comment, it sounds like this is caused by Zapier permissions not allowing the creation of files on their system. The code block that is erroring is pretty straightforward.
output = {'status_code' : ''}
key = 'xxxxxxxx'
url = 'https://' + key + ':@api.hellosign.com/v3/signature_request/send'
response = requests.get(input['pdf'])
with open('Test.pdf','wb') as f:
pdf = f.write(response.content)
files = {
'Doc' : pdf
}
param = {
'test_mode' : 1,
'title' : "Test from HelloSign",
'subject' : "Doc Ready",
'message' : 'Hi! Please sign the attached doc.',
'signing_redirect_url' : 'https://www.google.com/',
'signers[0][name]' : input['name'],
'signers[0][email_address]' : input['email']
}
r = requests.post(url=url,files = files, params=param)
output['status_code'] = r.status_code
What alternatives do I have to read the PDF without using open() so I can pass along the PDF to HelloSign to send off?
Upvotes: 0
Views: 1436
Reputation: 1542
This should work
output = {'status_code' : ''}
key = 'xxxxxxxx'
url = 'https://' + key + ':@api.hellosign.com/v3/signature_request/send'
response = requests.get(input['pdf'])
files = {
'file' : response.content
}
param = {
'test_mode' : 1,
'title' : "Test from HelloSign",
'subject' : "Doc Ready",
'message' : 'Hi! Please sign the attached doc.',
'signing_redirect_url' : 'https://www.google.com/',
'signers[0][name]' : input['name'],
'signers[0][email_address]' : input['email']
}
r = requests.post(url=url,files = files, params=param)
output['status_code'] = r.status_code
Upvotes: 1