1

i m calling user registration api in nextcloude using curl request in php but i m getting following response.

csrf check failed

my curl request is as follows.

$ownAdminname=“xxxx”;
$ownAdminpassword=“xxx”;

$ownconnect=“https://".$ownAdminname.":".$ownAdminpassword."@local.ngageapp.com”;

$username=‘xxxx’;
$password=‘xxx’;
$url = “{$ownconnect}/ocs/v1.php/cloud/users”;
$ownCloudPOSTArray = array(‘userid’ => $username, ‘password’ => $password );
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $ownCloudPOSTArray);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $ownAdminname.":".$ownAdminpassword);
$response = curl_exec($ch);
curl_close($ch);

Please I need help with this issue. Thanks in advance!

Angus
  • 70
  • 6
Abhijit Mali
  • 132
  • 2
  • 8

1 Answers1

1

From https://docs.nextcloud.com/server/12/admin_manual/configuration_user/user_provisioning_api.html:

All calls to OCS endpoints require the OCS-APIRequest header to be set to true.

Adding the header does the trick.

Blizzz
  • 108
  • 1
  • 5