API PHP Login doesnt work

I was testing CyberPanel API · Apiary.

Set up my hostnames URL and username and password however I get below error message

string(62) “{“userID”: 0, “loginStatus”: 0, “error_message”: “‘username’”}”

my PHP code

<?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://xxxxxxx:8090/api/loginAPI"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, "{ \"username\": \"myusername\", \"password\": \"mypassword\" }"); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/json" )); $response = curl_exec($ch); curl_close($ch); var_dump($response); ?>

Any idea how to fix this ? is it from my side or is it a bug?

Thank you,

Hi I also faced the same issue, the fix for this is the header type which is Content-Type: application/x-www-form-urlencoded"

I have creates a html file for this

With this the user is allowed to login and dashboard is loaded.