Json Debitoor API返回400个错误请求

Json Debitoor API返回400个错误请求,json,rest,api,post,jsonschema,Json,Rest,Api,Post,Jsonschema,我想通过我的PHP脚本创建发票。但是在我能够编程之前,我想先了解一下Debitoor的API 要创建发票,必须先创建发票草稿。您可以在此处找到: 我已经设置了所有请求的参数以使用/api/sales/draftinvoices/v3函数,但是,我总是收到400个错误的请求响应。。原因是模式 你们能告诉我我的失败在哪里吗? 我猜是有“线条”的东西。。。但我想说这一切都是正确的 这是我的要求: 请求作为文本: { "date": "2018-05-06", "dueDate": "2018

我想通过我的PHP脚本创建发票。但是在我能够编程之前,我想先了解一下Debitoor的API

要创建发票,必须先创建发票草稿。您可以在此处找到:

我已经设置了所有请求的参数以使用/api/sales/draftinvoices/v3函数,但是,我总是收到400个错误的请求响应。。原因是模式

你们能告诉我我的失败在哪里吗? 我猜是有“线条”的东西。。。但我想说这一切都是正确的

这是我的要求:

请求作为文本:

{
  "date": "2018-05-06",
  "dueDate": "2018-05-13",
  "notes": "Diese Rechnung ist vom Backend erstellt worden.",
  "customerName": "Max Mustermann",
  "customerAddress": "Mustermann Stra\u00dfe",
  "customerCountry": "DE",
  "currency": "EUR",
  "languageCode": "de-DE",
  "recargoTaxEnabled": false,
  "sent": false,
  "viewed": false,
  "displayAsPaid": false,
  "lines": {
    "taxEnabled": "false",
    "description": "Leistungszeitraum 06.04.2018 - 05.05.2018",
    "taxRate": "1.19",
    "productOrService": "product"
  }
}
这是我得到的回应:

全文如下:

{
  "message": "Error validating against schema",
  "id": "9905636b-fb65-41a0-8d25-4aa096d5347d",
  "code": "schema",
  "errors": [
    {
      "message": "is the wrong type",
      "value": {
        "taxEnabled": "false",
        "description": "Leistungszeitraum 06.04.2018 - 05.05.2018",
        "taxRate": "1.19",
        "productOrService": "product"
      },
      "type": "array",
      "property": "lines"
    }
  ],
  "body": {
    "date": "2018-05-06",
    "dueDate": "2018-05-13",
    "notes": "Diese Rechnung ist vom Backend erstellt worden.",
    "customerName": "Max Mustermann",
    "customerAddress": "Mustermann Stra\u00dfe",
    "customerCountry": "DE",
    "currency": "EUR",
    "languageCode": "de-DE",
    "recargoTaxEnabled": false,
    "sent": false,
    "viewed": false,
    "displayAsPaid": false,
    "lines": {
      "taxEnabled": "false",
      "description": "Leistungszeitraum 06.04.2018 - 05.05.2018",
      "taxRate": "1.19",
      "productOrService": "product"
    }
  }
}

亲切的问候和感谢

感谢您使用Debitoor API

你说得对。你的问题是线路问题。行应该是一个数组。您只发送了一个对象

另一个问题是您提供了
可征税:false
税率:1.19
。如果您将
taxEnabled
作为
false
提供,则应将税率设置为0。请记住,税率应该在0到100之间,最多两位小数

您的请求应该是这样的:

{
“行”:[
{
“可征税”:错误,
“说明”:“Leistungszeitraum 06.04.2018-05.05.2018”,
“税率”:0,
“数量”:1,
“单价”:1,
“产品或服务”:“产品”
}
]

致以最良好的祝愿

卡斯滕

移动开发者@debitor