Invoice creation using PHP SDK and API fails with redirect using 4.4.4

Using the latest version of InvoiceNinja the creation of invoices fails with the following error message:

PHP Fatal error:  Uncaught Exception: <!DOCTYPE html>
        <meta charset="UTF-8" />
        <meta http-equiv="refresh" content="0;url=http://ninja.test" />

        <title>Redirecting to http://ninja.test</title>
        Redirecting to <a href="http://ninja.test">http://ninja.test</a>.
</html> in my-project/vendor/invoiceninja/sdk-php/src/InvoiceNinja/Models/AbstractModel.php:185
Stack trace:
#0 my-project/vendor/invoiceninja/sdk-php/src/InvoiceNinja/Models/AbstractModel.php(78): InvoiceNinja\Models\AbstractModel::sendRequest('http://ninja....', '{"invoice_items...', 'POST')
#1 my-project/src/Controller/NinjaController.php(58): InvoiceNinja\Models\AbstractModel->save()
#2 {main}
  thrown in /usr/local/share/my-project/vendor/invoiceninja/sdk-php/src/InvoiceNinja/Models/AbstractModel.php on line 185

On the webserver I see that a HTTP code 302 is triggered:

"GET /api/v1/clients? HTTP/1.1" 200 36082 "-" "Invoice Ninja - PHP SDK"
"POST /api/v1/invoices?include=invitations HTTP/1.1" 302 420 "-" "Invoice Ninja - PHP SDK"

The Laravel error log does not show anything.
I have not been able to figure out what triggers the redirect response here. Is there any way to determine the root cause?
Thanks a lot for any helpful comments. :slight_smile:

Maybe the client isn’t set or found?

Thanks for the suggestion, Hillel, however, it does not seem to be the case. I had the invoice object dumped before saving it:

InvoiceNinja\Models\Invoice Object
    [invoice_items] => Array
            [0] => stdClass Object
                    [product_key] =>
                    [notes] => Item 1 Text
                    [cost] => 1000.000
                    [qty] => 16.500

            [1] => stdClass Object
                    [product_key] =>
                    [notes] => Item 2 Text
                    [cost] => 500.000
                    [qty] => 16.500


    [invitations] => Array

    [id] =>
    [client_id] => 23
    [tax_name1] => VAT
    [tax_rate1] => 19.00000
    [public_notes] => Random notes text

Hence, a client is set and thus should be known, right?

Maybe the client is deleted?

Thanks for the hint, that seems to be the case indeed. :slight_smile:

Glad to hear it!

FYI… in our next version the app will return an error message in this case rather than redirect.