XeroAPI / xero-php-oauth2

Xero PHP SDK for oAuth 2 generated from Xero API OpenAPI Spec 3.0
MIT License
91 stars 65 forks source link

Getting 500 internal server error while creating invoices in xero #141

Closed bilalswiftsolutions closed 4 years ago

bilalswiftsolutions commented 4 years ago

Im trying to create invoice in xero through this library webfox/xero-php-oauth2 and getting this error

XeroAPI \ XeroPHP \ ApiException (500) [500] Server error: `PUT https://api.xero.com/api.xro/2.0/Invoices?summarizeErrors=false&unitdp=2` resulted in a `500 Internal Server Error` response: {"Title":"An error occurred","Detail":"An error occurred in Xero. Check the API Status page http://status.developer.xero (truncated...)

invoice Creating Code

$apiInstance = resolve(\XeroAPI\XeroPHP\Api\AccountingApi::class);
        $invoice = new \XeroAPI\XeroPHP\Models\Accounting\Invoice; 
        $invoice->setType('APOVERPAYMENT')
        ->setContact('52f09f84-2078-49cc-8a62-6e27602ccb55')
        ->setDate('2020-07-01')
        ->setDueDate('2020-07-08');
        $invoices= new \XeroAPI\XeroPHP\Models\Accounting\Invoices;
        $invoices->setInvoices($invoice);
        $apiInstance->createInvoices($xeroCredentials->getTenantId(),$invoices,false,2);

I make sure that my app is connected with xero . also clear my cache . but still getting this error. tried to search from other platform but didn't get satisfactory answer.

bilalswiftsolutions commented 4 years ago

I made mistake while creating invoice . i was missing required parameters for invoice. $contact array and $lineItem array are necessary to pass in order to create invoice