Purpose
We call this method to set a given user's role in the given i2b2 project.
PHP example. Feel free to user other programming languages
function i2b2_set_role($user_name, $role, $project_id){
/*
* Construct set_role XML call and attach to message_body parent
* <pm:set_role>
* <user_name>mem61</user_name>
* <role>DATA_AGG</role>
* <project_id>ra_mart_test2</project_id>
* </pm:set_role>
*
* Returns: Boolean true when user role is set
*/
global $i2b2_pm_uri, $i2b2_domain, $i2b2_service_account_id, $i2b2_service_account_pw;
$request_xml = i2b2_header_xml($i2b2_pm_uri, $i2b2_domain, $i2b2_service_account_id, $i2b2_service_account_pw);
$request_xml .= "<pm:set_role>";
$request_xml .= " <user_name>$user_name</user_name>";
$request_xml .= " <role>$role</role>";
$request_xml .= " <project_id>$project_id</project_id>";
$request_xml .= "</pm:set_role>";
$request_xml .= i2b2_footer_xml();
$ch = curl_init($i2b2_pm_uri);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$request_xml");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
log_request($request_xml, $user_name . '-' . __FUNCTION__);
return $data;
}