Closed deemonic closed 3 years ago
@deemonic - a 400 error indicates invalid data.
Looking at your code example, there are several pieces of data you are getting from somewhere outside the code block.
Two places I would look - the "getLineItem" may not be using a valid Account Code. Also, getContact() method is unclear what you are returning.
We have additional SDK documentation you may want to look at https://xeroapi.github.io/xero-php-oauth2/docs/v2/accounting/index.html#api-Accounting-createInvoices
@deemonic - if you have any further question, let us know. Otherwise, we will go ahead and close this issue.
Describe the bug A clear and concise description of what the bug is.
I have been trying to create an invoice using the following package https://github.com/webfox/laravel-xero-oauth2. I have raised this as an issue on that repo too. I keep getting the following error
XeroAPI\XeroPHP\ApiException: [400] Client error: PUT https://api.xero.com/api.xro/2.0/Invoices?summarizeErrors=false resulted in a 400 Bad Request response: { "ErrorNumber": 14, "Type": "PostDataInvalidException", "Message": "JSON request body could not be read, Error (truncated...) in file C:\inetpub\sites\webhooks.crystallegal.com\vendor\xeroapi\xero-php-oauth2\lib\Api\AccountingApi.php on line 7453
I can see in the AccountingApi.php file that the request is serialize as JSON
To Reproduce Steps to reproduce the behavior:
I have successfully done the following
Created an oAuth2.0 instance (This is working) Added the required scopes for Contacts and Invoices in the Xero.php config file and re-connected my app using oAuth 2.0 I have succussfulyl created a contact in Xero using the API and return the contact ID which is used for the Invoice request Create a LineItems object as at least 1 Line item is required to create an invoice Here is my method
public function createInvoice(Request $request, OauthCredentialManager $xeroCredentials) {
//dd($invoices);
} Expected behavior
I would expect this to create an Invoice as I believe I have followed instructions form this package as well as the Xero documentation