我正在使用 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 Invoice API 端点得到的响应是
"{\"errors\":[{\"field\":\"\",\"message\":\"Forbidden\",\"code\":\"403\"}]}"
访问令牌和客户端 ID 均有效,我根据以下链接遵循发票的结构
https://developer.myob.com/api/essentials-accounting/endpoints/sale/invoices/
我在请求中包含的那些以前标记为必填但 MYOB 修改了 UI 的字段。
仅供参考,我可以从 MYOB 获取联系人、帐户和税款类型,只需将 Forbidden 403 消息返回以尝试发布发票。
您能提供的任何帮助将不胜感激。