Add User by CURL PHP
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2014 01:28 PM
Hello Good Day,
I am trying add user by curl php, but don't add only sent me the admin info, here it's the code
$data = array(
"userName" => "ECASAS",
"firstName" => "Eduardo",
"lastName" => "Casas",
"email" => "lgonzalez@emt.cl",
"password"=>"asdasd"
);
$str_data = json_encode($data);
$ch = curl_init();
$username='admin';
$password='*******'; // initiate curl
$url = "http://************/alfresco/service/api/people"; // where you want to post data
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_POST, true); // tell curl you want to post something
curl_setopt($ch, CURLOPT_POSTFIELDS, $str_data); // define what you want to post
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the output in string format
$output = curl_exec ($ch); // execute
curl_close ($ch); // close curl handle
var_dump($output); // show output
if sameone can help me please.
I am trying add user by curl php, but don't add only sent me the admin info, here it's the code
$data = array(
"userName" => "ECASAS",
"firstName" => "Eduardo",
"lastName" => "Casas",
"email" => "lgonzalez@emt.cl",
"password"=>"asdasd"
);
$str_data = json_encode($data);
$ch = curl_init();
$username='admin';
$password='*******'; // initiate curl
$url = "http://************/alfresco/service/api/people"; // where you want to post data
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_POST, true); // tell curl you want to post something
curl_setopt($ch, CURLOPT_POSTFIELDS, $str_data); // define what you want to post
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the output in string format
$output = curl_exec ($ch); // execute
curl_close ($ch); // close curl handle
var_dump($output); // show output
if sameone can help me please.
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2014 02:51 AM
Take a look at this forum post - https://forums.alfresco.com/comment/146735#comment-146735 where it is solved to invoke using the java code. You also need to ensure to pass the request data in valid json when you are invoking the webscript call.
Hope this helps.
Hope this helps.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2014 11:12 AM
Hi,
I solved the problem, i added this code curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));.
Thank you.
I solved the problem, i added this code curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));.
Thank you.
