我正在使用RestSharp将发票推送到MYOB上。
RestClient myobPostInvoicesClient = new RestClient("https://api.myob.com/");
RestRequest myobPostInvoicesRequest = new RestRequest("au/essentials/businesses/" + business_uid + "/sale/invoices", Method.POST);
myobPostInvoicesRequest.AddHeader("Authorization", "Bearer " + access_token);
myobPostInvoicesRequest.AddHeader("x-myobapi-key", clientId);
myobPostInvoicesRequest.AddHeader("x-myobapi-version", "v0");
myobPostInvoicesRequest.AddHeader("Content-Type", "application/json");
我发送到端点的 JSON 如下所示
{{
"contact": {
"uid": "26939970"
},
"invoiceNumber": "IV00000000082",
"issueDate": "2020-06-07T09:00:00",
"dueDate": "2020-07-07T09:00:00",
"gstInclusive": "true",
"status": "Open",
"lines": [
{
"unitOfMeasure": "Qty",
"quantity": 5.0,
"unitPrice": 1000.0,
"total": 5000.0,
"taxType": {
"uid": "10"
},
"account": {
"uid": "9"
},
"description": "Test Description"
}
]
}}
我从 MYOB 发票 API 端点返回的响应是
"{"errors":[{"field":"","message":"Forbidden","code":"403"}]}"
访问令牌和客户端 ID 都是有效的,我正在根据以下链接遵循发票的结构
https://developer.myob.com/api/essentials-accounting/endpoints/sale/invoices/
我在请求中包含的那些,其中以前标记为必填但 MYOB 修改了 UI 的字段。
仅供参考,我可以从MYOB获取联系人,帐户和数据类型,只需返回禁止的403消息以尝试发布发票即可。
您能提供的任何帮助将不胜感激。
如果您获得 403 禁止访问,则需要检查用于进行发布呼叫的帐户的权限。
请参阅此处以阅读有关帐户权限的信息
除了上面的链接
如何检查用户的访问权限
若要准确了解当前用户具有哪些权限,并确保他们具有应用程序正常运行的正确权限,请向 {{company_file_uri}}/{{company_file_id}}/CurrentUser 终结点发出 GET 请求。
以下响应告诉您用户对每个 URL 拥有哪些权限
{
"UserAccess": [
{
"ResourcePath": "https://{{company_file_uri}}/{{company_file_id}}/Banking/BankAccount/",
"Access": [
"GET"
]
},
{
"ResourcePath": "https://{{company_file_uri}}/{{company_file_id}}/Banking/ReceiveMoneyTxn/",
"Access": [
"GET",
"POST",
"PUT",
"DELETE"
]
},
...
]
}