【问题标题】:Zapier get PDF file using Zapier Developer PlatformZapier 使用 Zapier 开发者平台获取 PDF 文件
【发布时间】:2022-01-13 06:07:26
【问题描述】:

我在 Zapier 开发者平台中创建了一个自定义操作。我的任务是将 Xero 会计软件中的 PDF 文件加载到 Zapier 中,以便我可以在我的 zap 中使用它来附加到电子邮件。

到目前为止,我有下面的代码返回成功的响应,但不幸的是 PDF 文件总是空白:

const pdfURL = {
  url: 'https://api.xero.com/api.xro/2.0/Quotes/' + bundle.inputData.QuoteID,
  method: 'GET',
  headers: {
    'Accept': 'application/pdf',
    'Authorization': `Bearer ${bundle.authData.access_token}`,
    'Xero-tenant-id': bundle.inputData.TenantID
  }
};
const fileRequest = await z.request(pdfURL);
const url = await z.stashFile(fileRequest); // knownLength and filename will be sniffed from the request. contentType will be binary/octet-stream
return {url};

有什么想法可能是错的吗?

提前致谢。

【问题讨论】:

    标签: zapier zapier-cli


    【解决方案1】:

    我在存储 PDF 时遇到了类似的问题,我注意到如果我在调用中使用 raw: true,它实际上开始将数据存储在 zapier 为您保存的 pdf 文件中。

    试一试,让我知道它是否有效!

    const pdfURL = {
      url: 'https://api.xero.com/api.xro/2.0/Quotes/' + bundle.inputData.QuoteID,
      method: 'GET',
      headers: {
        'Accept': 'application/pdf',
        'Authorization': `Bearer ${bundle.authData.access_token}`,
        'Xero-tenant-id': bundle.inputData.TenantID
      },
      raw: true
    };
    const fileRequest = await z.request(pdfURL);
    const url = await z.stashFile(fileRequest); // knownLength and filename will be sniffed from the request. contentType will be binary/octet-stream
    return {url};
    

    【讨论】:

      猜你喜欢
      • 2015-11-22
      • 2021-07-18
      • 2019-08-15
      • 2019-07-31
      • 2021-09-25
      • 2019-11-10
      • 2018-01-06
      • 2018-11-07
      • 2020-06-04
      相关资源
      最近更新 更多