Problem with User Provisioning API (Error 997)

Hi this is my first post I’m new using nextcloud and I have an inconvenient one when creating user from my script.

This is my script:

include(‘Requests/library/Requests.php’);
Requests::register_autoloader();
$headers = array(
‘Content-Type’ => ’ application/x-www-form-urlencoded’,
‘OCS-APIRequest’ => ‘true’
);
$data = array(
‘userid’ => ‘“Frank”’,
‘password’ => ‘“frankspassword”’’
);

$response = Requests::post(‘http://admin:adminpass@localhost/ocs/v1.php/cloud/users’, $headers, $data);

echo $response->body;

and he always gives me this mistake:

failure 997 Current user is not logged in

Why this is happening?

Did you solve the problem?

I am facing the same issue…
Can you tell me what is your solution?