API error creating user " failure 998 Invalid query"

Hi
Im trying to use the API on nextcloud 16 ( lastest as of today)
On trying to create a user on my install via command line, using

curl -X POST http://admin:mypass@myinstall.com/ocs/v1.php/cloud/users -H "OCS-APIRequest: true" -d userid="newuser" -d password="newpassword

This works fine and a new user is created.

The problem is when i use curl -

$url = 'http://admin:mypass@myinstall.com/ocs/v1.php/cloud/users -H "OCS-APIRequest: true";

$data = [
'userid' => $username, 
'password' => $userpassword, 
];

$ch = curl_init($url);
//print_r($ch);die();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo "Response from curl :" . $response;

i get Response from curl : failure 998 Invalid query, please check the syntax. API specifications are here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services.

Any one how any ideas or advise that might help. be much appreciated.

Darren

space problem for me.
should be “OCS-APIRequest:true”

$url = 'http://admin:mypass@myinstall.com/ocs/v1.php/cloud/users -H "OCS-APIRequest:true";
Ive tried that and still the error 998.

Sorry it did not do the trick.

This seem good anyway.

998 means notfound.

docsnextcloud is down actually …

Do you have any info where you found the 998 means not found, ive looked for ages and cant find a thing.
Its weird how it works via SSH but not curl.

https://docs.nextcloud.com/server/14/developer_manual/core/externalapi.html
https://docs.nextcloud.com/server/16/developer_manual/core/externalapi.html

  • 100 - successful
  • 996 - server error
  • 997 - not authorized
  • 998 - not found
  • 999 - unknown error

Thanks for that.
Not sure what it’s not finding, as the command line actually works.
Anyone else have any ideas?
I can’t see that the API won’t work with curl or maybe I’m wrong. :thinking:

Surely someone has got this working ???