XERO PHP SDK - Createinvoiceattachment 抛出 401 未经授权的错误
XERO PHP SDK - Createinvoiceattachment throws 401 Unauthorized error
我正在尝试将文件附加到发票上。它抛出错误。租户 ID、发票 ID 正确。
Exception when calling
AccountingApi->createInvoiceAttachmentByFileName: [401] Client error:
PUT https://api.xero.com/api.xro/2.0/Invoices/b03b18ca-50b2-42fa-a585-aa5674b7ed03/Attachments/2New-Requirment-Oct2020.docx?IncludeOnline=true
resulted in a 401 Unauthorized
response:
{"Type":null,"Title":"Unauthorized","Status":401,"Detail":"AuthorizationUnsuccessful","Instance":"54c33c01-e168-47d5-abe
(truncated...)
我的密码是:
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' 范围包含在请求的范围中?
我正在尝试将文件附加到发票上。它抛出错误。租户 ID、发票 ID 正确。
Exception when calling AccountingApi->createInvoiceAttachmentByFileName: [401] Client error:
PUT https://api.xero.com/api.xro/2.0/Invoices/b03b18ca-50b2-42fa-a585-aa5674b7ed03/Attachments/2New-Requirment-Oct2020.docx?IncludeOnline=true
resulted in a401 Unauthorized
response: {"Type":null,"Title":"Unauthorized","Status":401,"Detail":"AuthorizationUnsuccessful","Instance":"54c33c01-e168-47d5-abe (truncated...)
我的密码是:
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' 范围包含在请求的范围中?