How to correctly make POST request to add an invoice?

Hi! :slight_smile:

I am trying to POST a new invoice via InvoiceNinja API:
https://app.swaggerhub.com/apis/invoiceninja/invoiceninja/5.3.28#/invoices/storeInvoice

I correctly set up request headers (I can GET data from API, etc).

But when I POST to /api/v1/invoices with body:

{
    "client_id": "Wkwvk1soJn",
    "design_id": "1VDtbOa5UA",
    "line_items": [
        {
            "product_key": "Product key",
            "cost": 54,
            "quantity": "6.5",
        },
        ...
    ]
}

I get:

{"message"=>"The given data was invalid.", "errors"=>{"client_id"=>["The client id field is required."]}}

There is client_id in the request body, but API says itโ€™s required. I donโ€™t see what I am doing wrong. Could anybody please help?

What headers are you passing in with the request?

Also if you are using PHP, check out our SDK which abstracts away all these issues

Thanks for the answer, David!

I am using Ruby.

Headers:

accept-encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
accept: */*
user-agent: Ruby
host: invoiceninja.site.com
x-api-secret: xxx
x-api-token: xxx
x-requested-with: XMLHttpRequest"

Am I missing something? :thinking:

Added headers (like in InvoiceNinja SwaggerHub):

Accept: application/json
Content-Type: application/json

Response changed:

{"message"=>"The given data was invalid.", "errors"=>{"is_amount_discount"=>["The is amount discount field must be true or false."], "discount"=>["The discount must be a number."]}}

I think I am fine at this point.

Thank you, David!