1 year ago
#382351
quinn_2000
PayPal REST API: get Web Profile ID – 400 Bad Request
I've got a problem with the PayPal REST API or at least I am getting an error back using Guzzle as client.
The PHP code:
$body = [
'name' => 'TestName982365923',
'presentation' => [
'brand_name' => 'Test Name',
'logo_image' => 'https://example.com/site/static/public/img/paypal-logo.png',
'locale_code' => 'DE',
],
];
$body_json = json_encode($body);
// New HTTP client
$client = new \GuzzleHttp\Client([
'base_uri' => $this->getApiBaseUrl(),
'debug' => true
]);
$options = [
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $this->getAccessToken(),
],
'body' => $body_json,
];
try {
$response = $client->request('POST', 'payment-experience/web-profiles/', $options);
} catch (\Exception $e) {
echo $e->getMessage();
$this->setErrorMessage($e->getMessage());
return false;
}
Returns:
- Trying 173.0.93.199:443...
- TCP_NODELAY set
- Connected to api.sandbox.paypal.com (173.0.93.199) port 443 (#0)
- ALPN, offering http/1.1
- Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
- successfully set certificate verify locations:
- CAfile: /Applications/MAMP/Library/OpenSSL/cert.pem CApath: none
- SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
- ALPN, server accepted to use http/1.1
- Server certificate:
- subject: C=US; ST=California; L=San Jose; O=PayPal, Inc.; CN=api.sandbox.paypal.com
- start date: Feb 7 00:00:00 2022 GMT
- expire date: Mar 10 23:59:59 2023 GMT
- subjectAltName: host "api.sandbox.paypal.com" matched cert's "api.sandbox.paypal.com"
- issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 High Assurance Server CA
- SSL certificate verify ok. > GET /v1/payment-experience/web-profile HTTP/1.1 Host: api.sandbox.paypal.com User-Agent: GuzzleHttp/6.5.5 curl/7.68.0 PHP/7.4.16 Content-Type: application/json Authorization: Bearer AXXXXXXXXXXXXXXXQ
- Mark bundle as not supporting multiuse < HTTP/1.1 404 Not Found < Content-Type: application/json < Content-Length: 131 < Connection: keep-alive < Date: Wed, 06 Apr 2022 12:49:23 GMT < Application_id: APP-80W284485P519543T < Cache-Control: max-age=0, no-cache, no-store, must-revalidate < Caller_acct_num: AK28QXXXULZL < Paypal-Debug-Id: 9e6XXXXe67ed9 < Strict-Transport-Security: max-age=31536000; includeSubDomains <
- Connection #0 to host api.sandbox.paypal.com left intact Client error:
POST https://api.sandbox.paypal.com/v1/payment-experience/web-profiles/
resulted in a400 Bad Request
response: {"name":"VALIDATION_ERROR","debug_id":"ba3XXXXX2d6","message":"Invalid request - see details","information_link":"http (truncated...)
When I put the same request into Paw (similar to Postman) I am getting a "HTTP/1.1 200 OK" back … with a "Webprofile ID". So I guess the problem is not my code itself, but Guzzle or my local MAMP? Is that part the main reason?
Mark bundle as not supporting multiuse < HTTP/1.1 404 Not Found
Guzzle 6.5
PHP 7.4.16 (curl: HTTP2 enabled)
Apache 2.4.46
Local dev is using https
php
paypal-sandbox
guzzle
guzzle6
0 Answers
Your Answer