如何使用 wp_remote_post() 更新 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);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)