XERO PHP SDK-Createinvoiceattachment抛出401未经授权的错误



我正在尝试将文档附加到发票上。它抛出错误。租户id、发票id正确。

调用时出现异常会计Api->createInvoiceAttachmentByFileName:[401]客户端错误:PUT https://api.xero.com/api.xro/2.0/Invoices/b03b18ca-50b2-42fa-a585-aa5674b7ed03/Attachments/2New-Requirment-Oct2020.docx?IncludeOnline=true导致CCD_ 2响应:{"类型":null,"标题":"未授权","状态":401,"详细信息":"授权未成功","实例":"54c33c01-e168-47d5-be(截断…(

我的代码是:

if (isset($_FILES["gfile1"]))
{  
$target_dir = "uploads/bills/";
$target_file = $target_dir . basename($_FILES["gfile1"]["name"]);
$FileType = pathinfo($target_file,PATHINFO_EXTENSION);      

$filename1 = $billid . basename($_FILES["gfile1"]["name"]);

$filename1 = str_replace(" ", "", $filename1);
$filename1 = str_replace("#", "", $filename1);              

$target_filenew = $target_dir . $filename1; 
move_uploaded_file($_FILES["gfile1"]["tmp_name"], $target_filenew); 
$attachmentFile = file_get_contents(base_url() . $target_filenew);
try {

$result = $accountingApi->createInvoiceAttachmentByFileName($xeroTenantId, $invid, $filename1, 
$attachmentFile, true);
} catch (Exception $e) {
echo 'Exception when calling AccountingApi->createInvoiceAttachmentByFileName: ',
$e->getMessage(), PHP_EOL;
}   
} 

附件需要使用不同的作用域。

在授权连接时,您是否将"accounting.attachments"范围包括在请求的范围中?

相关内容

  • 没有找到相关文章

最新更新