Creating invoice with API doesn't auto populate the cost/notes fields

Hi and thanks in advance for the help.

I’m running IN v3.7.2 self-hosted and things are generally working quite well. Thanks for the tools!

Running into a problem with the create invoice API.

Per the API Docs – “If the product_key is set and matches an existing record the product fields will be auto-populated”

I am setting the product_key in my JSON which exactly matches a product key in Products yet the notes and cost fields don’t autopopulate. Note if I am on the GUI and create an invoice, and add a product line item, everything does auto fill.

Pulling my hair out on this one. What could be wrong with what I am doing? Is this a product bug?

JSON to create the new invoice… (email does match a client and the client details do copy over, fwiw)


{
  "email": "25.noreply@testdomain.org",
  "invoice_status_id": 1,
"invoice_items":[{"product_key":"Big League"},{"product_key":"Big League"}]
}

Here is the relevant bit of the products api response…


{
    "data": [
        {
            "account_key": "jgdy8jtr33lnvbceihdkurlfep327132",
            "is_owner": true,
            "id": 57,
            "product_key": "Big League",
            "notes": "Invoice $ 8.00, Per Official $ 40.0, Organization $ 0.0, Treasurer $ 2.0, Booking Agent $ 5.0",
            "cost": "8.0000",
            "qty": "1.0000",
            "tax_name1": "",
            "tax_rate1": 0,
            "tax_name2": "",
            "tax_rate2": 0,
            "updated_at": 1508299442,
            "archived_at": null,
            "custom_value1": "101",
            "custom_value2": "2"
        },

Thoughts? Thanks in advance.

I’m not sure, here’s the relevant section of code:

https://github.com/invoiceninja/invoiceninja/blob/master/app/Http/Controllers/InvoiceApiController.php#L292

You also need to have the setting for product update enabled in the web portal for this to have effect.