【问题标题】:Debitoor API is returning 400 bad requestDebitoor API 返回 400 错误请求
【发布时间】:2018-05-06 16:53:41
【问题描述】:

我想通过我的 PHP 脚本创建发票。但在我能够对此进行编程之前,我想了解 Debitoor 的 API。

要创建发票,您必须先创建发票草稿。你可以在这里找到:/api/sales/draftinvoices/v3。

我已将所有请求的参数设置为使用 /api/sales/draftinvoices/v3 函数,但是,我总是收到 400 Bad Request 响应。原因是架构。

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

这是我的要求:

请求文本:

{
  "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"
    }
  }
}

诚挚的问候和感谢!

【问题讨论】:

    标签: json rest api post jsonschema


    【解决方案1】:

    感谢您使用 Debitoor API

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

    另一个问题是您提供了taxEnabled: false 和taxRate: 1.19。如果您提供 taxEnabled 为 false,则应将 taxRate 设置为 0。请记住,taxRate 应介于 0 和 100 之间,最多保留两位小数

    您的请求应如下所示:

    { "lines": [ { "taxEnabled": false, "description": "Leistungszeitraum 06.04.2018 - 05.05.2018", "taxRate": 0, "quantity": 1, "unitNetPrice": 1, "productOrService": "product" } ]

    最好的问候,

    卡斯滕

    移动开发者@Debitoor

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-16
      相关资源
      最近更新 更多