Skip to main content
added 9 characters in body
Source Link
Fokker
  • 385
  • 1
  • 20

I am trying to integrate a payment gateway with my headless magento 2 website.

So after the payment is processed/failed, the payment website makes a POST request to my API with x-www-form-encoded data, and it throws me the following error:

{"message":"Server cannot understand Content-Type HTTP header media type application/x-www-form-urlencoded","trace":null}

I've tried using: `$request_body = file_get_contents('php://input');

   $request_body = file_get_contents('php://input');

    $data = json_decode($request_body,true);`;

But this doesn't work either.

Normal form works, sending these params as JSON works too, but they are sending the params in x-www-form-encoded format, and we can't change that.

Please help!

I am trying to integrate a payment gateway with my headless magento 2 website.

So after the payment is processed/failed, the payment website makes a POST request to my API with x-www-form-encoded data, and it throws me the following error:

{"message":"Server cannot understand Content-Type HTTP header media type application/x-www-form-urlencoded","trace":null}

I've tried using: `$request_body = file_get_contents('php://input');

    $data = json_decode($request_body,true);`

But this doesn't work either.

Normal form works, sending these params as JSON works too, but they are sending the params in x-www-form-encoded format, and we can't change that.

Please help!

I am trying to integrate a payment gateway with my headless magento 2 website.

So after the payment is processed/failed, the payment website makes a POST request to my API with x-www-form-encoded data, and it throws me the following error:

{"message":"Server cannot understand Content-Type HTTP header media type application/x-www-form-urlencoded","trace":null}

I've tried using:

   $request_body = file_get_contents('php://input');

    $data = json_decode($request_body,true);

But this doesn't work either.

Normal form works, sending these params as JSON works too, but they are sending the params in x-www-form-encoded format, and we can't change that.

Please help!

Source Link
Fokker
  • 385
  • 1
  • 20

Magento 2 API: 3rd Party makes a post request to magento API with x-www-form-encoded data

I am trying to integrate a payment gateway with my headless magento 2 website.

So after the payment is processed/failed, the payment website makes a POST request to my API with x-www-form-encoded data, and it throws me the following error:

{"message":"Server cannot understand Content-Type HTTP header media type application/x-www-form-urlencoded","trace":null}

I've tried using: `$request_body = file_get_contents('php://input');

    $data = json_decode($request_body,true);`

But this doesn't work either.

Normal form works, sending these params as JSON works too, but they are sending the params in x-www-form-encoded format, and we can't change that.

Please help!