This topic contains 1 reply, has 2 voices, and was last updated by Roman Grebenchuk 8 years, 7 months ago.
- Topic
I have tried create a new user via the api to OroC but it response “Internal Server Error”
This is my code:
$userName = ‘test’;
$userPassword = ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’;$nonce = uniqid();
$created = date(‘c’);
$digest = base64_encode(sha1(base64_decode($nonce) . $created . $userPassword, true));$wsseHeader = “Authorization: WSSE profile=\”UsernameToken\”\n”;
$wsseHeader.= sprintf(
‘X-WSSE: UsernameToken Username=”%s”, PasswordDigest=”%s”, Nonce=”%s”, Created=”%s”‘,
$userName,
$digest,
$nonce,
$created
);$userData[‘owner’] = array(‘id’ => 3);
$userData[‘roles’] = array(array(‘id’ => 3));
$userData[‘enabled’] = true;
$userData[‘username’] = ‘test’;
$userData[‘password’] = ‘123456’;
$userData[‘firstName’] = ‘Test’;
$userData[‘lastName’] = ‘Tran’;
$userData[’email’] = ‘test@gmail.com’;
$userData[‘phone’] = ‘0909111222’;
$userData = array(‘user’ => $userData);
$headers = array();
//$headers[] = ‘Accept: application/json’;
$headers[] = ‘Content-Type:application/json’;
$headers[] = $wsseHeader;
// INITIATE CURL
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, ‘http://domain.com/api/rest/latest/users.json’);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 0); //Seconds until timeout
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($ch, CURLOPT_HEADER, true);
//echo json_encode($data);die();
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($userData));
// POST AND GET RESPONSE
$response = curl_exec( $ch );curl_close( $ch );
echo $response;
The forum ‘OroCRM – How do I? Questions’ is closed to new topics and replies.