Invoice API - Request is not well-formed, syntactically incorrect, or violates schema

ayrancd
Contributor
Contributor

Following this API article https://developer.paypal.com/docs/api/invoicing/v2/#invoices_create

 

I'm getting this error using PHP language:

 

Array ( [name] => INVALID_REQUEST [message] => Request is not well-formed, syntactically incorrect, or violates schema. [debug_id] => c0c75e12510f5 [details] => Array ( ) [links] => Array ( [0] => Array ( [href] => https://developer.paypal.com/docs/api/invoicing/#errors [method] => GET ) ) )

 

Can't figure out what I am missing. Below are all fields I'm sending to Paypal api:

 

$invoice->fields['detail']["invoice_number"] = "12345";
$invoice->fields['detail']["currency_code"] = "USD";
$invoice->fields['detail']["invoice_date"] = "2020-09-04";
$invoice->fields['detail']["note"] = "Thank you for your business.";
$invoice->fields['detail']["memo"] = "This is invoice is due in 24hrs after being generated.";
$invoice->fields['detail']["payment_term"]["term_type"] = "DUE_ON_DATE_SPECIFIED";
$invoice->fields['detail']["payment_term"]["due_date"] = "2020-09-05";

//seller
$invoice->fields['invoicer']["business_name"] = "Business name here";
$invoice->fields['invoicer']["name"]["given_name"] = "Cezar";
$invoice->fields['invoicer']["name"]["surname"] = "Ayran";

$invoice->fields['invoicer']["address"]["address_line_1"] = "533 Cece Lake";
$invoice->fields['invoicer']["address"]["address_line_2"] = "Apt 0101";
$invoice->fields['invoicer']["address"]["admin_area_2"] = "West Palm Beach";
$invoice->fields['invoicer']["address"]["admin_area_1"] = "FL";
$invoice->fields['invoicer']["address"]["postal_code"] = "33437";
$invoice->fields['invoicer']["address"]["country_code"] = "US";
$invoice->fields['invoicer']["email_address"] = "seller email";

 

//buyer - billing
$invoice->fields["primary_recipients"][0]["billing_info"]["business_name"] = "Evanice Company";
$invoice->fields["primary_recipients"][0]["billing_info"]["name"]["given_name"] = "Evanice";
$invoice->fields["primary_recipients"][0]["billing_info"]["name"]["surname"] = "D";

$invoice->fields["primary_recipients"][0]["billing_info"]["address"]["address_line_1"] = "Av Benjamin Constant";
$invoice->fields["primary_recipients"][0]["billing_info"]["address"]["admin_area_2"] = "Boca Raton";
$invoice->fields["primary_recipients"][0]["billing_info"]["address"]["admin_area_1"] = "FL";
$invoice->fields["primary_recipients"][0]["billing_info"]["address"]["postal_code"] = "12345";
$invoice->fields["primary_recipients"][0]["billing_info"]["address"]["country_code"] = "US";
$invoice->fields["primary_recipients"][0]["billing_info"]["email_address"] = "buyer email";

//shipping
$invoice->fields["primary_recipients"][0]["shipping_info"]["business_name"] = "Evanice Company";
$invoice->fields["primary_recipients"][0]["shipping_info"]["name"]["given_name"] = "Evanice";
$invoice->fields["primary_recipients"][0]["shipping_info"]["name"]["surname"] = "D";
$invoice->fields["primary_recipients"][0]["shipping_info"]["address"]["address_line_1"] = "Av Benjamin Constant";
$invoice->fields["primary_recipients"][0]["shipping_info"]["address"]["admin_area_2"] = "Boca Raton";
$invoice->fields["primary_recipients"][0]["shipping_info"]["address"]["admin_area_1"] = "FL";
$invoice->fields["primary_recipients"][0]["shipping_info"]["address"]["postal_code"] = "12345";
$invoice->fields["primary_recipients"][0]["shipping_info"]["address"]["country_code"] = "BR";
$invoice->fields["primary_recipients"][0]["shipping_info"]["email_address"] = "buyer email";

//items
$invoice->fields["items"][0]["name"] = "Product title here";
$invoice->fields["items"][0]["description"] = "Description here";
$invoice->fields["items"][0]["quantity"] = 1;
$invoice->fields["items"][0]["unit_amount"]["currency_code"] = "USD";
$invoice->fields["items"][0]["unit_amount"]["value"] = "80.00";

 

Any idea of what I am missing? Tks

Login to Me Too
11 REPLIES 11

MTS_Stefan
Moderator
Moderator

Hello Ayrancd,

 

What do you mean by public URL? 

Sandbox means sandbox, no emails are sent so you will not receive any other, then in dev portal > notifications.

You should see it in both accounts unless the receiver account was spelled differently in which case the system will assign it to an account that does not exist. In live that non-existing email address would receive an email about an invoice and the request to create an account to handle it.

The GET calls are just to gain access to all details of a transaction / invoice.

 

Kind Regards,

Stefan

Login to Me Too

pzauner
Contributor
Contributor

Hello Stefan,

 

I have the same problem, but changing the invoicer's name, surname and email to the one on the business paypal account did not sort it out.

I do the API call in Python with the request library. My data dictionary looks like this, I can print it, so syntactically everything should be fine.

 

{'detail': {'invoice_date': '2021-08-19', 'currency_code': 'EUR', 'note': 'Danke für Ihren Einkauf!', 'term': 'Rückerstattungen bis 2 Werktage vor Termin'}, 'invoicer': {'name': {'given_name': 'Max', 'surname': 'Mustermann'}, 'address': {'address_line_1': 'Test Str. 20', 'address_line_2': 'Etage 2', 'admin_area_2': 'Teststadt', 'admin_area_1': 'BY', 'postal_code': '12345', 'country_code': 'DE'}, 'email_address': 'mail thats used in the paypal business account', 'phones': [{'country_code': '0049', 'national_numer': '1711433650', 'phone_type': 'MOBILE'}], 'website': 'www.lernwelt.de'}, 'primary_recipients': [{'billing_info': {'name': {'given_name': 'Patrick', 'surname': 'Zauner'}, 'address': {'address_line_1': 'Freibierstraße 2', 'admin_area_2': 'Teststadt', 'postal_code': '12345', 'country_code': 'DE'}, 'email_address': 'buyers mail'}, 'shipping_info': {'name': {'given_name': 'Patrick', 'surname': 'Zauner'}, 'address': {'address_line_1': 'Freibierstraße 2', 'admin_area_2': 'Teststadt', 'postal_code': '12345', 'country_code': 'DE'}}}], 'items': [{'name': 'Nachhilfestunde', 'description': '2. Klasse, Mathe, Kommentar: Addition und Subtraktion bis 100', 'quantity': '1', 'unit_amount': {'currency_code': 'EUR', 'value': '10.00'}, 'unit_of_measure': 'QUANTITY'}]}

 

Do you have any idea why I still get an INVALID_REQUEST back ?

{'name': 'INVALID_REQUEST', 'message': 'Request is not well-formed, syntactically incorrect, or violates schema.', 'debug_id': '95555fd4d8d2c', 'details': [], 'links': [{'href': 'https://developer.paypal.com/docs/api/invoicing/#errors', 'method': 'GET'}]}

 

kind regards,

 

Patrick

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.