Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to make external API call with basic authentification from Symfony 4 controller?

As mentioned in the question I am trying to call this Adyen API with specific authentification credentials and passing JSON object,
Using Curl it is done like this.

curl https://pal-test.adyen.com/pal/servlet/Recurring/v68/disable \
-U "ws@Company.login":"Pa$$W0rd" \
-H "Content-Type: application/json" \
-d '{
  "merchantAccount": "exampleMerchantAccount",
  "shopperReference": "exampleShopperReference"
    }'

I tried to do this using HTTPClient Request:

$params = array(
        "merchantAccount" => "exampleMerchantAccount",
        "shopperReference" => "exampleShopperReference"
    );
$result = $this->client->request('POST', 'https://pal-test.adyen.com/pal/servlet/Recurring/v68/disable', $params);

But I still can’t understand how to pass the basic authentification credentials.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any help please .

>Solution :

As written in the documentation, add it to the parameters like this:

$result = $this->client->request(
  'POST',
  'https://pal-test.adyen.com/pal/servlet/Recurring/v68/disable',
  [
   'auth_basic' => ['ws@Company.login', 'Pa$$W0rd'],
   'body' => $params,
  ]
);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading