You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用Debitoor /api/sales/draftinvoices/v3接口返回400错误,请求排查

Hey Jan, let's dig into that schema-related 400 error you're hitting with the Debitoor draft invoice API. Schema issues almost always come down to missing required fields, incorrect data types, or formatting mismatches—here are the most common culprits to check off first:

  • Double-check all required fields are present

    Debitoor's v3 draft invoice endpoint has non-negotiable required fields like contactId, lineItems, and currencyCode. Even one missing required field will trigger a schema error. For example, lineItems can't be an empty array, and each line item needs at minimum description, quantity, and unitPrice.

  • Fix data type mismatches
    This is the #1 cause of schema errors I see. Watch out for these common mistakes:

    • Sending a string (like "2") instead of an integer for quantity
    • Wrapping unitPrice in quotes (it needs to be a numeric value, not a string)
    • Passing contactId as a number instead of a string (Debitoor uses string-based IDs for most resources)
    • Using string values like "true" instead of actual boolean true/false for fields like isVatIncluded
  • Validate date formats
    If you're including dates (e.g., issueDate, dueDate), Debitoor requires ISO 8601 format—think YYYY-MM-DD for dates, or full ISO timestamps if you're using datetime values. Formats like 05/10/2024 will break the schema validation immediately.

  • Verify nested object structure
    Fields like lineItems or vatRate are nested objects/arrays that need to follow the exact schema structure. For example, if you're specifying a VAT rate for a line item, the vatRate object must include both id (string) and rate (number) properties—you can't skip either.

  • Inspect the full error response details
    Debitoor's 400 responses usually include a detailed errors array that tells you exactly which field is causing the problem. In your PHP script, you can decode this to get specific clues:

    $response = curl_exec($yourCurlHandle);
    $errorData = json_decode($response, true);
    print_r($errorData['errors']);
    

    This will output something like "contactId is a required field" or "unitPrice must be a numeric value", which cuts straight to the issue.

  • Pre-validate your payload with a JSON schema tool
    Before sending your request, paste your JSON payload into a JSON schema validator (you can use a local tool or a simple web-based one) and compare it against Debitoor's published schema for the draft invoice endpoint. This will catch subtle formatting issues your eye might miss.

If you can share the specific error message from the response or a redacted version of your payload, I can help narrow it down even further—but these checks should cover most schema-related 400s you might be facing.

内容的提问来源于stack exchange,提问作者Jan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:39:53