Patient Register return 400 bad request

While call the patient register i got 400 bad request.

My Code,

$data = new stdClass();
$data->title = “Mr”;
$data->fname = “Antony”;
$data->mname = “”;
$data->lname = “Mark”;
$data->street = “456 Tree Lane”;
$data->postal_code = “08642”;
$data->city = “FooTown”;
$data->state = “FL”;
$data->country_code = “US”;
$data->phone_contact = “123-456-7890”;
$data->DOB = “1992-02-02”;
$data->sex = “Male”;
$data->race = “”;
$data->ethnicity = “”;

    $data = json_encode($data);
   // echo $data; exit;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,"https://openemr.xyz.com/apis/default/api/patient");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS ,$data);
    curl_setopt($ch, CURLOPT_FAILONERROR, true); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJhcFFvWjRXa05aS3VNWHpIc2tNY3ZFaW1RVmNKV3B2V2ZmZjQyak............................',
            'Content-Type:application/json',
            
        ));


    // receive server response ...
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    curl_exec($ch);

OpenEMR Response:

The requested URL returned error: 400 Bad Request

Please provide as the solution.

Thanks

I got the following errors in my openemr log,

[php7:notice]
[pid 7170]
[client 157.49.255.189:59659]
[2021-02-22T05:38:44.185696+00:00]
OpenEMR.ERROR: dispatch.php failed token verify for resource {“resource”:"/default/api/facility"} [][Mon Feb 22 05:38:51.223776 2021]
[php7:notice]
[pid 7172]
[client 157.49.255.189:59658]
OpenEMR Error - api site error, so forced exit[Mon Feb 22 05:38:54.277167 2021]
[php7:notice]
[pid 6383]
[client 157.49.255.189:59661]
OpenEMR Error - api site error, so forced exit[Mon Feb 22 05:38:57.949295 2021]
[php7:notice]
[pid 6385]
[client 157.49.255.189:59667]
OpenEMR Error - api site error, so forced exit[Mon Feb 22 05:39:51.667201 2021]
[php7:notice]
[pid 11103]
[client 34.75.105.142:36426]
OpenEMR Error - api site error, so forced exit[Mon Feb 22 05:51:36.043811 2021]
[php7:notice]
[pid 7178]
[client 34.75.105.142:36538]
PHP Notice: Undefined index: contacts in /var/www/openemr/src/RestControllers/AuthorizationController.php on line 367[Mon Feb 22 05:51:36.043837 2021]
[php7:notice]
[pid 7178]
[client 34.75.105.142:36538]
PHP Notice: Undefined index: redirect_uris in /var/www/openemr/src/RestControllers/AuthorizationController.php on line 368[Mon Feb 22 05:53:15.858849 2021]
[php7:notice]
[pid 7178]
[client 34.75.105.142:36548] [2021-02-22T05:53:15.858721+00:00]
OpenEMR.ERROR: OpenEMR Error - userid or tokenid not available, so forced exit [] [][Mon Feb 22 05:53:39.479417 2021]
[php7:notice] [pid 6382] [client 34.75.105.142:36550] [2021-02-22T05:53:39.479282+00:00]
OpenEMR.ERROR: OpenEMR Error - userid or tokenid not available, so forced exit [] [][Mon Feb 22 05:57:08.644361 2021]
[php7:notice]
[pid 6386]
[client 106.198.106.232:61500]
PHP Notice: Only variables should be passed by reference in /var/www/openemr/src/Menu/MainMenuRole.php on line 68, referer: https://openemr.test.com/interface/login/login.php?site=default

Please provide me a solution.