UNPROCESSABLE_ENTITY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I keep getting this UNPROCESSABLE_ENTITY error when I try to create an order, strongly the first time I tried I worked, after that It didn't work anymore, I deleted the app and create new credentials but that didn't work either, anyone have an idea?
the error is
{"name":"UNPROCESSABLE_ENTITY","details":[{"location":"body","issue":"VALIDATION_ERROR","description":"VALIDATION_ERROR"}],"message":"The requested action could not be performed, semantically incorrect, or failed business validation.","debug_id":"30a12b8b72e34","links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-VALIDATION_ERROR","rel":"information_link","method":"GET"}]}
class Command(BaseCommand):
def handle(self, *args, **options):
clientid = "xxx"
secret = "xxx"
#do an paypal authentication
url = "https://api.sandbox.paypal.com/v1/oauth2/token"
headers = {'Accept': 'application/json', 'Accept-Language': 'en_US'}
data = {'grant_type': 'client_credentials'}
r = requests.post(url, headers=headers, data=data, auth=(clientid, secret))
print(r.json())
access_token = r.json()['access_token']
print(access_token)
url = 'https://api-m.sandbox.paypal.com/v2/checkout/orders'
headers = {
'PayPal-Request-Id': '0ed5f89f718b',
'Content-Type': 'application/json',
'Authorization': 'Bearer '+access_token
}
payload = {
"intent": "CAPTURE",
"purchase_units": [
{
"reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
"amount": {
"currency_code": "EUR",
"value": "1.00"
}
}
],
"payment_source": {
"ideal": {
"country_code": "NL",
"name": "John Doe",
"bic": "INGBNL2A"
}
},
"processing_instruction": "ORDER_COMPLETE_ON_PAYMENT_APPROVAL",
"application_context": {
"locale": "en-NL",
"return_url": "https://example.com/returnUrl",
"cancel_url": "https://example.com/cancelUrl"
}
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.text)
the code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good day @GerdNL,
Thank you for posting to the PayPal community.
The Create order API calls failed due to "Bad Request" with HTTP_RESPONSE_CODE=422 via Sandbox environment.
https://developer.paypal.com/api/rest/reference/orders/v2/errors/#create-order
I would suggest to cross check and pass valid request in your Create order API.
If your still facing any issues, please create a MTS ticket via - https://www.paypal-support.com/s/?language=en_US with the detail information and error details.
Sincerely,
Chiranjeevi
PayPal/Braintree MTS
If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- link my PayPal business account with my WordPress website , but it's not work ?! in PayPal Payments Standard
- I met the 422 response, and tries a lot solutions in the community but still not work in REST APIs
- [UNPROCESSABLE_ENTITY], but payment went through in PayPal Payments Standard
- API TRANSACTION_REFUSED in Sandbox when Capturing Payment in REST APIs
- Getting this error from paypal , popup closing automatically itself when it opens in SDKs