Good Postman request don't work on my php website

Good morning. On Postman, I created a query which returns me a result but the generated code (PHP-CURL) which seems correct to me does not return “false”
Method POST
Postman Config:
Params => nothing
Authorization => default (inherit auth …)
Headers => content-type: application/json, data-type: jsonp
Body => {
“Username”: “user-name”,
“Password”: “pass-word”
}

Postman return:

{
    "access_token": "xxxxxxx",
    "token_type": "xxx",
    "expires_in": 10799,
    "userName": "user-name",
    "issued": "2024-04-26T08:58:24Z",
    "expires": "2024-04-26T11:58:24Z",
    "error": "",
    "error_description": ""
}

Postman code generate:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://XXX/api',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "Username": "user-name",
    "Password": "pass-word"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'dataType: jsonp'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

But $response = false

For information, I work on a local server

Thans for your help

Hi @liflowam.

Welcome to the Postman Community. I don’t fully understand your question. It is worth noting that Postman generated code “might” not work right out of the box due to several reasons which can include missing params, or missing authorization/authentication in the request. The generated code is meant to give you a good head start with replicating that same request in a language if your choosing.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.