如何使用 wp_remote_post() 更新 Xero 发票

时间:2020-12-22 17:29:13

标签: php wordpress xero-api xero

我正在尝试更新 Xero 发票的发票模板。我的问题是我收到 400 错误和回复说:

NoDataProcessedException No data has been processed for this endpoint. This endpoint is expecting Invoice data to be specifed in the request body

所以我的身份验证工作正常,但它声称我的帖子请求正文中没有数据。正如您在下面的代码中看到的,我在请求正文中指定了数据。那么是我格式错误还是我做错了什么?

$xeroInvoiceId = '7b601c90-642b-4b6c-9a21-3969ff339cb0';

$updateInvoiceArgs = array(
    'headers' => array(
        'xero-tenant-id' => $tenantId,
         'Authorization' => 'Bearer ' . $refreshTokenBody->access_token,
     ),
     'body' => array(
         'InvoiceID' => $xeroInvoiceId,
         'BrandingThemeID' => '5d4dd402-c851-497e-aae1-9ff265c0d15a'
      )
); 

            
$res = wp_remote_post('https://api.xero.com/api.xro/2.0/Invoices/' . $xeroInvoiceId, $updateInvoiceArgs);

var_dump($res);

0 个答案:

没有答案