id
stringlengths 14
16
| text
stringlengths 33
5.27k
| source
stringlengths 105
270
|
---|---|---|
51e606fd7f73-7 | )
[last_name] => stdClass Object
(
[name] => last_name
[value] => Jacoby
)
)
)
[1] => stdClass Object
(
[id] => 11c263ef-ff61-71ff-f090-4f7cb6fc9f68
[module_name] => Contacts
[name_value_list] => stdClass Object
(
[id] => stdClass Object
(
[name] => id
[value] => 11c263ef-ff61-71ff-f090-4f7cb6fc9f68
)
[first_name] => stdClass Object
(
[name] => first_name | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records_With_Related_Info/index.html |
51e606fd7f73-8 | (
[name] => first_name
[value] => Ike
)
[last_name] => stdClass Object
(
[name] => last_name
[value] => Gassaway
)
)
)
)
[relationship_list] => Array
(
[0] => stdClass Object
(
[link_list] => Array
(
[0] => stdClass Object
(
[name] => email_addresses
[records] => Array
(
[0] => stdClass Object
(
[link_value] => stdClass Object
(
[id] => stdClass Object | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records_With_Related_Info/index.html |
51e606fd7f73-9 | (
[id] => stdClass Object
(
[name] => id
[value] => 13066f13-d6ea-405c-0f95-4f7cb6fa3a08
)
[email_address] => stdClass Object
(
[name] => email_address
[value] => [email protected]
)
[opt_out] => stdClass Object
(
[name] => opt_out
[value] => 0
)
[primary_address] => stdClass Object
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records_With_Related_Info/index.html |
51e606fd7f73-10 | [primary_address] => stdClass Object
(
[name] => primary_address
[value] =>
)
)
)
[1] => stdClass Object
(
[link_value] => stdClass Object
(
[id] => stdClass Object
(
[name] => id
[value] => 13e3d111-b226-c363-4832-4f7cb699a3a0
)
[email_address] => stdClass Object
(
[name] => email_address | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records_With_Related_Info/index.html |
51e606fd7f73-11 | (
[name] => email_address
[value] => [email protected]
)
[opt_out] => stdClass Object
(
[name] => opt_out
[value] => 1
)
[primary_address] => stdClass Object
(
[name] => primary_address
[value] =>
)
)
)
)
)
)
)
[1] => stdClass Object
(
[link_list] => Array
(
[0] => stdClass Object
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records_With_Related_Info/index.html |
51e606fd7f73-12 | (
[0] => stdClass Object
(
[name] => email_addresses
[records] => Array
(
[0] => stdClass Object
(
[link_value] => stdClass Object
(
[id] => stdClass Object
(
[name] => id
[value] => 16aeaf8b-b31f-943d-3844-4f7cb6ac63f2
)
[email_address] => stdClass Object
(
[name] => email_address
[value] => [email protected] | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records_With_Related_Info/index.html |
51e606fd7f73-13 | [value] => [email protected]
)
[opt_out] => stdClass Object
(
[name] => opt_out
[value] => 0
)
[primary_address] => stdClass Object
(
[name] => primary_address
[value] =>
)
)
)
[1] => stdClass Object
(
[link_value] => stdClass Object
(
[id] => stdClass Object
(
[name] => id | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records_With_Related_Info/index.html |
51e606fd7f73-14 | (
[name] => id
[value] => 173bacf5-5ea6-3906-d91d-4f7cb6c6e883
)
[email_address] => stdClass Object
(
[name] => email_address
[value] => [email protected]
)
[opt_out] => stdClass Object
(
[name] => opt_out
[value] => 1
)
[primary_address] => stdClass Object
(
[name] => primary_address | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records_With_Related_Info/index.html |
51e606fd7f73-15 | (
[name] => primary_address
[value] =>
)
)
)
)
)
)
)
)
)
Â
Last modified: 2023-02-03 21:09:36 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records_With_Related_Info/index.html |
818899da472b-0 | This API has been succeeded by a new version. It is recommended to upgrade to the latest API.
Creating or Updating Teams
Overview
A PHP example demonstrating how to manipulate teams using cURL and the v4_1 REST API.
Note: If you are creating a private team for a user, you will need to set private to true and populate the associated_user_id populated. You should also populate the name and name_2 properties with the users first and last name.
Example
<?php
$url = "http://{site_url}/service/v4_1/rest.php";
$username = "admin";
$password = "password";
//function to make cURL request
function call($method, $parameters, $url)
{
ob_start();
$curl_request = curl_init(); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_or_Updating_Teams/index.html |
818899da472b-1 | ob_start();
$curl_request = curl_init();
curl_setopt($curl_request, CURLOPT_URL, $url);
curl_setopt($curl_request, CURLOPT_POST, 1);
curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($curl_request, CURLOPT_HEADER, 1);
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_or_Updating_Teams/index.html |
818899da472b-2 | $jsonEncodedData = json_encode($parameters);
$post = array(
"method" => $method,
"input_type" => "JSON",
"response_type" => "JSON",
"rest_data" => $jsonEncodedData
);
curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($curl_request);
curl_close($curl_request);
$result = explode("\r\n\r\n", $result, 2);
$response = json_decode($result[1]);
ob_end_flush();
return $response;
}
//login -------------------------------------------- | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_or_Updating_Teams/index.html |
818899da472b-3 | return $response;
}
//login --------------------------------------------
$login_parameters = array(
"user_auth" => array(
"user_name" => $username,
"password" => md5($password),
"version" => "1"
),
"application_name" => "RestTest",
"name_value_list" => array(),
);
$login_result = call("login", $login_parameters, $url);
/*
echo "<pre>";
print_r($login_result);
echo "</pre>";
*/
//get session id
$session_id = $login_result->id;
//create team -----------------------------------------------
$set_entry_parameters = array( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_or_Updating_Teams/index.html |
818899da472b-4 | $set_entry_parameters = array(
// session id
"session" => $session_id,
// The name of the module that the record will be create in.
"module_name" => "Teams",
// array of arrays for the record attributes
"name_value_list" => array(
/* Setting the id with a valid record id will update the record.
array(
"name" => "id",
"value" => "47dbab1d-bd78-09e8-4392-5256b4501d90"
),
*/
array(
"name" => "name",
"value" => "My Team"
),
array(
"name" => "description", | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_or_Updating_Teams/index.html |
818899da472b-5 | ),
array(
"name" => "description",
"value" => "My new team"
),
//Whether the team is private.
//Private teams will have the associated_user_id populated.
array(
"name" => "private",
"value" => 0
),
),
);
$set_entry_result = call("set_entry", $set_entry_parameters, $url);
echo "<pre>";
print_r($set_entry_result);
echo "</pre>";
?>
Result
stdClass Object
(
[id] => 5c35a3be-4601-fb45-3afd-52ab78b03f89
[entry_list] => stdClass Object
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_or_Updating_Teams/index.html |
818899da472b-6 | [entry_list] => stdClass Object
(
[name] => stdClass Object
(
[name] => name
[value] => My Team
)
[description] => stdClass Object
(
[name] => description
[value] => My new team
)
[private] => stdClass Object
(
[name] => private
[value] =>
)
)
)
Last modified: 2023-02-03 21:09:36 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_or_Updating_Teams/index.html |
c528764306be-0 | This API has been succeeded by a new version. It is recommended to upgrade to the latest API.
Retrieving Records by Email Domain
Overview
A PHP example demonstrating how to retrieve email addresses based on an email domain with the search_by_module and get_entries methods using cURL and the v4_1 REST API.
When using the search_by_module method, the email address information is not returned in the result. Due to this behavior, we will gather the record ids and pass them back to the get_entries method to fetch our related email addresses.
Example
<?php
$url = "http://{site_url}/service/v4_1/rest.php";
$username = "admin";
$password = "password";
//function to make cURL request
function call($method, $parameters, $url)
{ | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-1 | function call($method, $parameters, $url)
{
ob_start();
$curl_request = curl_init();
curl_setopt($curl_request, CURLOPT_URL, $url);
curl_setopt($curl_request, CURLOPT_POST, 1);
curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($curl_request, CURLOPT_HEADER, 1);
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-2 | curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);
$jsonEncodedData = json_encode($parameters);
$post = array(
"method" => $method,
"input_type" => "JSON",
"response_type" => "JSON",
"rest_data" => $jsonEncodedData
);
curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($curl_request);
curl_close($curl_request);
$result = explode("\r\n\r\n", $result, 2);
$response = json_decode($result[1]);
ob_end_flush(); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-3 | ob_end_flush();
return $response;
}
//login --------------------------------------------
$login_parameters = array(
"user_auth" => array(
"user_name" => $username,
"password" => md5($password),
"version" => "1"
),
"application_name" => "RestTest",
"name_value_list" => array(),
);
$login_result = call("login", $login_parameters, $url);
/*
echo "<pre>";
print_r($login_result);
echo "</pre>";
*/
//get session id
$session_id = $login_result->id;
//search_by_module ------------------------------------------------- | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-4 | //search_by_module -------------------------------------------------
$search_by_module_parameters = array(
"session" => $session_id,
'search_string' => '%@example.com',
'modules' => array(
'Accounts',
'Contacts',
'Leads',
),
'offset' => 0,
'max_results' => 1,
'assigned_user_id' => '',
'select_fields' => array('id'),
'unified_search_only' => false,
'favorites' => false
);
$search_by_module_results = call('search_by_module', $search_by_module_parameters, $url);
/*
echo '<pre>'; | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-5 | /*
echo '<pre>';
print_r($search_by_module_results);
echo '</pre>';
*/
$record_ids = array();
foreach ($search_by_module_results->entry_list as $results)
{
$module = $results->name;
foreach ($results->records as $records)
{
foreach($records as $record)
{
if ($record->name = 'id')
{
$record_ids[$module][] = $record->value;
//skip any additional fields
break;
}
}
}
}
$get_entries_results = array();
$modules = array_keys($record_ids); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-6 | $modules = array_keys($record_ids);
foreach($modules as $module)
{
$get_entries_parameters = array(
//session id
'session' => $session_id,
//The name of the module from which to retrieve records
'module_name' => $module,
//An array of record IDs
'ids' => $record_ids[$module],
//The list of fields to be returned in the results
'select_fields' => array(
'name',
),
//A list of link names and the fields to be returned for each link name
'link_name_to_fields_array' => array(
array(
'name' => 'email_addresses',
'value' => array( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-7 | 'name' => 'email_addresses',
'value' => array(
'email_address',
'opt_out',
'primary_address'
),
),
),
//Flag the record as a recently viewed item
'track_view' => false,
);
$get_entries_results[$module] = call('get_entries', $get_entries_parameters, $url);
}
echo '<pre>';
print_r($get_entries_results);
echo '</pre>';
Result
Array
(
[Accounts] => stdClass Object
(
[entry_list] => Array
(
[0] => stdClass Object
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-8 | (
[0] => stdClass Object
(
[id] => 1bb7ef28-64b9-cbd5-e7d6-5282a3b96953
[module_name] => Accounts
[name_value_list] => stdClass Object
(
[name] => stdClass Object
(
[name] => name
[value] => Underwater Mining Inc.
)
)
)
[1] => stdClass Object
(
[id] => efbc0c4e-cc72-f843-b6ed-5282a38dad7f
[module_name] => Accounts
[name_value_list] => stdClass Object
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-9 | [name_value_list] => stdClass Object
(
[name] => stdClass Object
(
[name] => name
[value] => 360 Vacations
)
)
)
)
[relationship_list] => Array
(
[0] => stdClass Object
(
[link_list] => Array
(
[0] => stdClass Object
(
[name] => email_addresses
[records] => Array
(
[0] => stdClass Object
(
[link_value] => stdClass Object
(
[email_address] => stdClass Object | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-10 | (
[email_address] => stdClass Object
(
[name] => email_address
[value] => [email protected]
)
[opt_out] => stdClass Object
(
[name] => opt_out
[value] => 0
)
[primary_address] => stdClass Object
(
[name] => primary_address
[value] =>
)
)
)
[1] => stdClass Object
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-11 | [1] => stdClass Object
(
[link_value] => stdClass Object
(
[email_address] => stdClass Object
(
[name] => email_address
[value] => [email protected]
)
[opt_out] => stdClass Object
(
[name] => opt_out
[value] => 0
)
[primary_address] => stdClass Object
(
[name] => primary_address
[value] =>
)
) | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-12 | )
)
)
)
)
)
)
[1] => stdClass Object
(
[link_list] => Array
(
[0] => stdClass Object
(
[name] => email_addresses
[records] => Array
(
[0] => stdClass Object
(
[link_value] => stdClass Object
(
[email_address] => stdClass Object
(
[name] => email_address
[value] => [email protected]
) | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-13 | )
[opt_out] => stdClass Object
(
[name] => opt_out
[value] => 0
)
[primary_address] => stdClass Object
(
[name] => primary_address
[value] =>
)
)
)
[1] => stdClass Object
(
[link_value] => stdClass Object
(
[email_address] => stdClass Object
(
[name] => email_address | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-14 | (
[name] => email_address
[value] => [email protected]
)
[opt_out] => stdClass Object
(
[name] => opt_out
[value] => 0
)
[primary_address] => stdClass Object
(
[name] => primary_address
[value] =>
)
)
)
)
)
)
)
)
)
[Contacts] => stdClass Object
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-15 | )
)
[Contacts] => stdClass Object
(
[entry_list] => Array
(
[0] => stdClass Object
(
[id] => 24330979-0e39-f9ec-2622-5282a372f39b
[module_name] => Contacts
[name_value_list] => stdClass Object
(
[name] => stdClass Object
(
[name] => name
[value] => Errol Goldberg
)
)
)
[1] => stdClass Object
(
[id] => 2542dad2-85f3-5529-3a30-5282a3104e31
[module_name] => Contacts | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-16 | [module_name] => Contacts
[name_value_list] => stdClass Object
(
[name] => stdClass Object
(
[name] => name
[value] => Luis Deegan
)
)
)
)
[relationship_list] => Array
(
[0] => stdClass Object
(
[link_list] => Array
(
[0] => stdClass Object
(
[name] => email_addresses
[records] => Array
(
[0] => stdClass Object
(
[link_value] => stdClass Object
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-17 | [link_value] => stdClass Object
(
[email_address] => stdClass Object
(
[name] => email_address
[value] => [email protected]
)
[opt_out] => stdClass Object
(
[name] => opt_out
[value] => 0
)
[primary_address] => stdClass Object
(
[name] => primary_address
[value] =>
)
)
)
[1] => stdClass Object | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-18 | )
[1] => stdClass Object
(
[link_value] => stdClass Object
(
[email_address] => stdClass Object
(
[name] => email_address
[value] => [email protected]
)
[opt_out] => stdClass Object
(
[name] => opt_out
[value] => 1
)
[primary_address] => stdClass Object
(
[name] => primary_address
[value] =>
) | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-19 | [value] =>
)
)
)
)
)
)
)
[1] => stdClass Object
(
[link_list] => Array
(
[0] => stdClass Object
(
[name] => email_addresses
[records] => Array
(
[0] => stdClass Object
(
[link_value] => stdClass Object
(
[email_address] => stdClass Object
(
[name] => email_address
[value] => [email protected] | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-20 | [value] => [email protected]
)
[opt_out] => stdClass Object
(
[name] => opt_out
[value] => 0
)
[primary_address] => stdClass Object
(
[name] => primary_address
[value] =>
)
)
)
[1] => stdClass Object
(
[link_value] => stdClass Object
(
[email_address] => stdClass Object
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-21 | [email_address] => stdClass Object
(
[name] => email_address
[value] => [email protected]
)
[opt_out] => stdClass Object
(
[name] => opt_out
[value] => 1
)
[primary_address] => stdClass Object
(
[name] => primary_address
[value] =>
)
)
)
)
)
)
)
)
)
[Leads] => stdClass Object
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-22 | )
)
[Leads] => stdClass Object
(
[entry_list] => Array
(
[0] => stdClass Object
(
[id] => 83abeeff-5e71-0f06-2e5f-5282a3f04f41
[module_name] => Leads
[name_value_list] => stdClass Object
(
[name] => stdClass Object
(
[name] => name
[value] => Caryn Wert
)
)
)
[1] => stdClass Object
(
[id] => 2a3b304b-5167-8432-d4e7-5282a300eabb | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-23 | [module_name] => Leads
[name_value_list] => stdClass Object
(
[name] => stdClass Object
(
[name] => name
[value] => Marco Castonguay
)
)
)
)
[relationship_list] => Array
(
[0] => stdClass Object
(
[link_list] => Array
(
[0] => stdClass Object
(
[name] => email_addresses
[records] => Array
(
[0] => stdClass Object
(
[link_value] => stdClass Object
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-24 | [link_value] => stdClass Object
(
[email_address] => stdClass Object
(
[name] => email_address
[value] => [email protected]
)
[opt_out] => stdClass Object
(
[name] => opt_out
[value] => 0
)
[primary_address] => stdClass Object
(
[name] => primary_address
[value] =>
)
)
)
)
)
) | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-25 | )
)
)
)
)
[1] => stdClass Object
(
[link_list] => Array
(
[0] => stdClass Object
(
[name] => email_addresses
[records] => Array
(
[0] => stdClass Object
(
[link_value] => stdClass Object
(
[email_address] => stdClass Object
(
[name] => email_address
[value] => [email protected]
)
[opt_out] => stdClass Object
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c528764306be-26 | [opt_out] => stdClass Object
(
[name] => opt_out
[value] => 0
)
[primary_address] => stdClass Object
(
[name] => primary_address
[value] =>
)
)
)
)
)
)
)
)
)
)
Last modified: 2023-02-03 21:09:36 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Records_by_Email_Domain/index.html |
c2d23fb2e5f2-0 | This API has been succeeded by a new version. It is recommended to upgrade to the latest API.
Retrieving Email Attachments
Overview
A PHP example demonstrating how to retrieve an email and its attachments from using the get_entry and get_note_attachment methods using cURL and the v4_1 REST API.
This example will retrieve a specified email record by its ID and write the attachments to the local filesystem.
Example
<?php
$url = "http://{site_url}/service/v4_1/rest.php";
$username = "admin";
$password = "password";
//function to make cURL request
function call($method, $parameters, $url)
{
ob_start();
$curl_request = curl_init();
curl_setopt($curl_request, CURLOPT_URL, $url); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-1 | curl_setopt($curl_request, CURLOPT_POST, 1);
curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($curl_request, CURLOPT_HEADER, 1);
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);
$jsonEncodedData = json_encode($parameters);
$post = array(
"method" => $method,
"input_type" => "JSON", | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-2 | "method" => $method,
"input_type" => "JSON",
"response_type" => "JSON",
"rest_data" => $jsonEncodedData
);
curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($curl_request);
curl_close($curl_request);
$result = explode("\r\n\r\n", $result, 2);
$response = json_decode($result[1]);
ob_end_flush();
return $response;
}
//login ---------------------------------------------
$login_parameters = array(
"user_auth" => array(
"user_name" => $username,
"password" => md5($password), | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-3 | "password" => md5($password),
"version" => "1"
),
"application_name" => "RestTest",
"name_value_list" => array(),
);
$login_result = call("login", $login_parameters, $url);
/*
echo "<pre>";
print_r($login_result);
echo "</pre>";
*/
//get session id
$session_id = $login_result->id;
//retrieve the email ---------------------------------------------
// email id of an email with an attachment
$email_id = '5826bd75-527a-a736-edf5-5205421467bf';
// use get_entry to get the email contents
$get_entry_parameters = array(
'session' => $session_id, | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-4 | 'session' => $session_id,
'module_name' => 'Emails',
'id' => $email_id,
'select_fields' => array(),
'link_name_to_fields_array' => array(
array(
'name' => 'notes',
'value' => array(
'id',
'name',
'file_mime_type',
'filename',
'description',
),
),
),
'track_view' => false
);
$get_entry_result = call('get_entry', $get_entry_parameters, $url);
//Email record contents
echo "<pre>";
print_r($get_entry_result);
echo "</pre>"; | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-5 | print_r($get_entry_result);
echo "</pre>";
if (!isset($get_entry_result->entry_list[0]))
{
echo "Email not found!";
die();
}
if (!isset($get_entry_result->relationship_list) || count($get_entry_result->relationship_list) == 0)
{
echo "No attachments found!";
die();
}
//retrieve any attachments ---------------------------------------------
foreach ($get_entry_result->relationship_list[0][0]->records as $key => $attachmentInfo)
{
$get_note_attachment_parameters = array(
'session' => $session_id,
'id' => $attachmentInfo->id->value,
); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-6 | 'id' => $attachmentInfo->id->value,
);
$get_note_attachment_result = call('get_note_attachment', $get_note_attachment_parameters, $url);
//attachment contents
echo "<pre>";
print_r($get_note_attachment_result);
echo "</pre>";
$file_name = $get_note_attachment_result->note_attachment->filename;
//decode and get file contents
$file_contents = base64_decode($get_note_attachment_result->note_attachment->file);
//write file
file_put_contents($file_name, $file_contents);
}
Result
//Email Result
stdClass Object
(
[entry_list] => Array | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-7 | //Email Result
stdClass Object
(
[entry_list] => Array
(
[0] => stdClass Object
(
[id] => 5826bd75-527a-a736-edf5-5205421467bf
[module_name] => Emails
[name_value_list] => stdClass Object
(
[assigned_user_name] => stdClass Object
(
[name] => assigned_user_name
[value] => Administrator
)
[modified_by_name] => stdClass Object
(
[name] => modified_by_name
[value] => Administrator
)
[created_by_name] => stdClass Object
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-8 | [created_by_name] => stdClass Object
(
[name] => created_by_name
[value] => Administrator
)
[team_id] => stdClass Object
(
[name] => team_id
[value] => 1
)
[team_set_id] => stdClass Object
(
[name] => team_set_id
[value] => 1
)
[team_name] => stdClass Object
(
[name] => team_name
[value] => Global
)
[id] => stdClass Object
(
[name] => id | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-9 | (
[name] => id
[value] => 5826bd75-527a-a736-edf5-5205421467bf
)
[date_entered] => stdClass Object
(
[name] => date_entered
[value] => 2013-08-09 19:28:00
)
[date_modified] => stdClass Object
(
[name] => date_modified
[value] => 2013-08-09 19:29:08
)
[assigned_user_id] => stdClass Object
(
[name] => assigned_user_id
[value] => 1
)
[modified_user_id] => stdClass Object | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-10 | )
[modified_user_id] => stdClass Object
(
[name] => modified_user_id
[value] => 1
)
[created_by] => stdClass Object
(
[name] => created_by
[value] => 1
)
[deleted] => stdClass Object
(
[name] => deleted
[value] => 0
)
[from_addr_name] => stdClass Object
(
[name] => from_addr_name
[value] => SugarCRM
)
[to_addrs_names] => stdClass Object
(
[name] => to_addrs_names | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-11 | (
[name] => to_addrs_names
[value] => [email protected]
)
[description_html] => stdClass Object
(
[name] => description_html
[value] =>
)
[description] => stdClass Object
(
[name] => description
[value] =>
)
[date_sent] => stdClass Object
(
[name] => date_sent
[value] => 2013-08-09 19:28:00
)
[message_id] => stdClass Object
(
[name] => message_id
[value] =>
)
[message_uid] => stdClass Object | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-12 | )
[message_uid] => stdClass Object
(
[name] => message_uid
[value] =>
)
[name] => stdClass Object
(
[name] => name
[value] => Example
)
[type] => stdClass Object
(
[name] => type
[value] => out
)
[status] => stdClass Object
(
[name] => status
[value] => read
)
[flagged] => stdClass Object
(
[name] => flagged
[value] => 0
)
[reply_to_status] => stdClass Object
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-13 | [reply_to_status] => stdClass Object
(
[name] => reply_to_status
[value] => 0
)
[intent] => stdClass Object
(
[name] => intent
[value] => pick
)
[mailbox_id] => stdClass Object
(
[name] => mailbox_id
[value] =>
)
[parent_name] => stdClass Object
(
[name] => parent_name
[value] => Having trouble adding new items
)
[parent_type] => stdClass Object
(
[name] => parent_type
[value] => Cases
) | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-14 | [value] => Cases
)
[parent_id] => stdClass Object
(
[name] => parent_id
[value] => 116d4d46-928c-d4af-c22e-518ae4eb13fc
)
)
)
)
[relationship_list] => Array
(
[0] => Array
(
[0] => stdClass Object
(
[name] => notes
[records] => Array
(
[0] => stdClass Object
(
[id] => stdClass Object
(
[name] => id | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-15 | (
[name] => id
[value] => 1b63a8f9-ce67-6aad-b5a4-52054af18c47
)
[name] => stdClass Object
(
[name] => name
[value] => Example.zip
)
[file_mime_type] => stdClass Object
(
[name] => file_mime_type
[value] => application/zip
)
[filename] => stdClass Object
(
[name] => filename
[value] => Example2.zip
)
[description] => stdClass Object | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-16 | )
[description] => stdClass Object
(
[name] => description
[value] =>
)
[_empty_] => stdClass Object
(
[name] =>
[value] =>
)
)
[1] => stdClass Object
(
[id] => stdClass Object
(
[name] => id
[value] => 592f382d-b633-fd5f-803e-5205423a6d0b
)
[name] => stdClass Object
(
[name] => name
[value] => Example2.zip | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-17 | [value] => Example2.zip
)
[file_mime_type] => stdClass Object
(
[name] => file_mime_type
[value] => application/zip
)
[filename] => stdClass Object
(
[name] => filename
[value] => Example2.zip
)
[description] => stdClass Object
(
[name] => description
[value] =>
)
[_empty_] => stdClass Object
(
[name] =>
[value] =>
)
)
)
) | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-18 | )
)
)
)
)
)
)
//Attachment 1 Result
stdClass Object
(
[note_attachment] => stdClass Object
(
[id] => 1b63a8f9-ce67-6aad-b5a4-52054af18c47
[filename] => Example.zip
[file] => UEsDBAoAAAAIAOujCEOkMbvsNa0AAMCFAgAXAAAARmlsZXMvaW
[related_module_id] => 5826bd75-527a-a736-edf5-5205421467bf
[related_module_name] => Emails
)
)
//Attachment 2 Result
stdClass Object
(
[note_attachment] => stdClass Object | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
c2d23fb2e5f2-19 | stdClass Object
(
[note_attachment] => stdClass Object
(
[id] => 592f382d-b633-fd5f-803e-5205423a6d0b
[filename] => Example2.zip
[file] => AEUoaAAARmlslsZXMvaWZXujCEOkMbvsNa0AAMCFAgAXAAAARm
[related_module_id] => 5826bd75-527a-a736-edf5-5205421467bf
[related_module_name] => Emails
)
)
Related
Â
Last modified: 2023-02-03 21:09:36 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Email_Attachments/index.html |
5434f45c495a-0 | This API has been succeeded by a new version. It is recommended to upgrade to the latest API.
Retrieving Related Records
Overview
A PHP example demonstrating how to retrieve a list of related records with the get_relationships method using cURL and the v4_1 REST API.
This example will retrieve a list of leads related to a specific target list.
Example
<?php
$url = "http://{site_url}/service/v4_1/rest.php";
$username = "admin";
$password = "password";
//function to make cURL request
function call($method, $parameters, $url)
{
ob_start();
$curl_request = curl_init();
curl_setopt($curl_request, CURLOPT_URL, $url); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Related_Records/index.html |
5434f45c495a-1 | curl_setopt($curl_request, CURLOPT_POST, 1);
curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($curl_request, CURLOPT_HEADER, 1);
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);
$jsonEncodedData = json_encode($parameters);
$post = array(
"method" => $method,
"input_type" => "JSON", | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Related_Records/index.html |
5434f45c495a-2 | "method" => $method,
"input_type" => "JSON",
"response_type" => "JSON",
"rest_data" => $jsonEncodedData
);
curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($curl_request);
curl_close($curl_request);
$result = explode("\r\n\r\n", $result, 2);
$response = json_decode($result[1]);
ob_end_flush();
return $response;
}
//login ---------------------------------------------
$login_parameters = array(
"user_auth" => array(
"user_name" => $username,
"password" => md5($password), | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Related_Records/index.html |
5434f45c495a-3 | "password" => md5($password),
"version" => "1"
),
"application_name" => "RestTest",
"name_value_list" => array(),
);
$login_result = call("login", $login_parameters, $url);
/*
echo "<pre>";
print_r($login_result);
echo "</pre>";
*/
//get session id
$session_id = $login_result->id;
//retrieve related list ------------------------------
$get_relationships_parameters = array(
'session'=>$session_id,
//The name of the module from which to retrieve records.
'module_name' => 'ProspectLists',
//The ID of the specified module bean. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Related_Records/index.html |
5434f45c495a-4 | //The ID of the specified module bean.
'module_id' => '76d0e694-ef66-ddd5-9bdf-4febd3af44d5',
//The relationship name of the linked field from which to return records.
'link_field_name' => 'leads',
//The portion of the WHERE clause from the SQL statement used to find the related items.
'related_module_query' => '',
//The related fields to be returned.
'related_fields' => array(
'id',
'first_name',
'last_name',
),
//For every related bean returned, specify link field names to field information.
'related_module_link_name_to_fields_array' => array(
),
//To exclude deleted records | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Related_Records/index.html |
5434f45c495a-5 | ),
//To exclude deleted records
'deleted'=> '0',
//order by
'order_by' => '',
//offset
'offset' => 0,
//limit
'limit' => 5,
);
$get_relationships_result = call("get_relationships", $get_relationships_parameters, $url);
echo "<pre>";
print_r($get_relationships_result);
echo "</pre>";
?>
Results
stdClass Object
(
[entry_list] => Array
(
[0] => stdClass Object
(
[id] => 117c26c0-11d4-7b8b-cb8f-4f7cb6823dd8
[module_name] => Leads | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Related_Records/index.html |
5434f45c495a-6 | [module_name] => Leads
[name_value_list] => stdClass Object
(
[id] => stdClass Object
(
[name] => id
[value] => 117c26c0-11d4-7b8b-cb8f-4f7cb6823dd8
)
[first_name] => stdClass Object
(
[name] => first_name
[value] => Diane
)
[last_name] => stdClass Object
(
[name] => last_name
[value] => Mckamey
)
)
)
[1] => stdClass Object
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Related_Records/index.html |
5434f45c495a-7 | )
)
[1] => stdClass Object
(
[id] => 142faeef-1a19-b53a-b780-4f7cb600c553
[module_name] => Leads
[name_value_list] => stdClass Object
(
[id] => stdClass Object
(
[name] => id
[value] => 142faeef-1a19-b53a-b780-4f7cb600c553
)
[first_name] => stdClass Object
(
[name] => first_name
[value] => Leonor
)
[last_name] => stdClass Object
(
[name] => last_name | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Related_Records/index.html |
5434f45c495a-8 | (
[name] => last_name
[value] => Reser
)
)
)
)
[relationship_list] => Array
(
)
)
Â
Last modified: 2023-02-03 21:09:36 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Related_Records/index.html |
16c413eeb21c-0 | This API has been succeeded by a new version. It is recommended to upgrade to the latest API.
Retrieving a List of Records
Overview
A PHP example demonstrating how to retrieve a list of records from a module with the get_entry_list method using cURL and the v4_1 REST API.
This example will retrieve a list of leads.
Example
<?php
$url = "http://{site_url}/service/v4_1/rest.php";
$username = "admin";
$password = "password";
//function to make cURL request
function call($method, $parameters, $url)
{
ob_start();
$curl_request = curl_init();
curl_setopt($curl_request, CURLOPT_URL, $url); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records/index.html |
16c413eeb21c-1 | curl_setopt($curl_request, CURLOPT_POST, 1);
curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($curl_request, CURLOPT_HEADER, 1);
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);
$jsonEncodedData = json_encode($parameters);
$post = array(
"method" => $method,
"input_type" => "JSON", | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records/index.html |
16c413eeb21c-2 | "method" => $method,
"input_type" => "JSON",
"response_type" => "JSON",
"rest_data" => $jsonEncodedData
);
curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($curl_request);
curl_close($curl_request);
$result = explode("\r\n\r\n", $result, 2);
$response = json_decode($result[1]);
ob_end_flush();
return $response;
}
//login -----------------------------------------
$login_parameters = array(
"user_auth" => array(
"user_name" => $username,
"password" => md5($password), | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records/index.html |
16c413eeb21c-3 | "password" => md5($password),
"version" => "1"
),
"application_name" => "RestTest",
"name_value_list" => array(),
);
$login_result = call("login", $login_parameters, $url);
/*
echo "<pre>";
print_r($login_result);
echo "</pre>";
*/
//get session id
$session_id = $login_result->id;
//get list of records --------------------------------
$get_entry_list_parameters = array(
//session id
'session' => $session_id,
//The name of the module from which to retrieve records
'module_name' => 'Leads',
//The SQL WHERE clause without the word "where". | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records/index.html |
16c413eeb21c-4 | //The SQL WHERE clause without the word "where".
'query' => "",
//The SQL ORDER BY clause without the phrase "order by".
'order_by' => "",
//The record offset from which to start.
'offset' => '0',
//Optional. A list of fields to include in the results.
'select_fields' => array(
'id',
'name',
'title',
),
/*
A list of link names and the fields to be returned for each link name.
Example: 'link_name_to_fields_array' => array(array('name' => 'email_addresses', 'value' => array('id', 'email_address', 'opt_out', 'primary_address')))
*/ | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records/index.html |
16c413eeb21c-5 | */
'link_name_to_fields_array' => array(
),
//The maximum number of results to return.
'max_results' => '2',
//To exclude deleted records
'deleted' => '0',
//If only records marked as favorites should be returned.
'Favorites' => false,
);
$get_entry_list_result = call('get_entry_list', $get_entry_list_parameters, $url);
echo '<pre>';
print_r($get_entry_list_result);
echo '</pre>';
?>
Result
stdClass Object
(
[result_count] => 2
[total_count] => 200
[next_offset] => 2
[entry_list] => Array
( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records/index.html |
16c413eeb21c-6 | [entry_list] => Array
(
[0] => stdClass Object
(
[id] => 18124607-69d1-b158-47ff-4f7cb69344f7
[module_name] => Leads
[name_value_list] => stdClass Object
(
[id] => stdClass Object
(
[name] => id
[value] => 18124607-69d1-b158-47ff-4f7cb69344f7
)
[name] => stdClass Object
(
[name] => name
[value] => Bernie Worthey
)
[title] => stdClass Object
(
[name] => title | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records/index.html |
16c413eeb21c-7 | (
[name] => title
[value] => Senior Product Manager
)
)
)
[1] => stdClass Object
(
[id] => 1cdfddc1-2759-b007-8713-4f7cb64c2e9c
[module_name] => Leads
[name_value_list] => stdClass Object
(
[id] => stdClass Object
(
[name] => id
[value] => 1cdfddc1-2759-b007-8713-4f7cb64c2e9c
)
[name] => stdClass Object
(
[name] => name
[value] => Bobbie Kohlmeier
) | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records/index.html |
16c413eeb21c-8 | [value] => Bobbie Kohlmeier
)
[title] => stdClass Object
(
[name] => title
[value] => Director Operations
)
)
)
)
[relationship_list] => Array
(
)
)
Â
Last modified: 2023-02-03 21:09:36 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Records/index.html |
7df7ec303a2c-0 | This API has been succeeded by a new version. It is recommended to upgrade to the latest API.
Creating Documents
Overview
A PHP example demonstrating how to create a document using set_entry and a document revision with the set_document_revision method using cURL and the v4_1 REST API.
Example
<?php
$url = "http://{site_url}/service/v4_1/rest.php";
$username = "admin";
$password = "password";
//function to make cURL request
function call($method, $parameters, $url)
{
ob_start();
$curl_request = curl_init();
curl_setopt($curl_request, CURLOPT_URL, $url);
curl_setopt($curl_request, CURLOPT_POST, 1); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_Documents/index.html |
7df7ec303a2c-1 | curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($curl_request, CURLOPT_HEADER, 1);
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);
$jsonEncodedData = json_encode($parameters);
$post = array(
"method" => $method,
"input_type" => "JSON",
"response_type" => "JSON",
"rest_data" => $jsonEncodedData
); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_Documents/index.html |
7df7ec303a2c-2 | "rest_data" => $jsonEncodedData
);
curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($curl_request);
curl_close($curl_request);
$result = explode("\r\n\r\n", $result, 2);
$response = json_decode($result[1]);
ob_end_flush();
return $response;
}
//login -----------------------------------------------------
$login_parameters = array(
"user_auth" => array(
"user_name" => $username,
"password" => md5($password),
"version" => "1"
),
"application_name" => "RestTest", | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_Documents/index.html |
7df7ec303a2c-3 | ),
"application_name" => "RestTest",
"name_value_list" => array(),
);
$login_result = call("login", $login_parameters, $url);
/*
echo "<pre>";
print_r($login_result);
echo "</pre>";
*/
//get session id
$session_id = $login_result->id;
//create document --------------------------------------------
$set_entry_parameters = array(
//session id
"session" => $session_id,
//The name of the module
"module_name" => "Documents",
//Record attributes
"name_value_list" => array(
//to update a record, pass in a record id as commented below | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_Documents/index.html |
7df7ec303a2c-4 | //to update a record, pass in a record id as commented below
//array("name" => "id", "value" => "9b170af9-3080-e22b-fbc1-4fea74def88f"),
array("name" => "document_name", "value" => "Example Document"),
array("name" => "revision", "value" => "1"),
),
);
$set_entry_result = call("set_entry", $set_entry_parameters, $url);
echo "<pre>";
print_r($set_entry_result);
echo "</pre>";
$document_id = $set_entry_result->id;
//create document revision ------------------------------------ | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_Documents/index.html |
7df7ec303a2c-5 | //create document revision ------------------------------------
$contents = file_get_contents ("/path/to/example_document.txt");
$set_document_revision_parameters = array(
//session id
"session" => $session_id,
//The attachment details
"note" => array(
//The ID of the parent document.
'id' => $document_id,
//The binary contents of the file.
'file' => base64_encode($contents),
//The name of the file
'filename' => 'example_document.txt',
//The revision number
'revision' => '1',
),
); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_Documents/index.html |
7df7ec303a2c-6 | 'revision' => '1',
),
);
$set_document_revision_result = call("set_document_revision", $set_document_revision_parameters, $url);
echo "<pre>";
print_r($set_document_revision_result);
echo "</pre>";
?>
Result
//set_entry result
stdClass Object
(
[id] => b769cf46-7881-a369-314d-50abaa238c62
[entry_list] => stdClass Object
(
[document_name] => stdClass Object
(
[name] => document_name
[value] => Example Document
)
[revision] => stdClass Object
(
[name] => revision | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_Documents/index.html |
7df7ec303a2c-7 | [revision] => stdClass Object
(
[name] => revision
[value] => 1
)
)
)
//set_document_revision result
stdClass Object
(
[id] => e83f97b9-b818-2d04-1aeb-50abaa8303b5
)
Â
Last modified: 2023-02-03 21:09:36 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_Documents/index.html |
7317680883b0-0 | This API has been succeeded by a new version. It is recommended to upgrade to the latest API.
Retrieving a List of Fields From a Module
Overview
A PHP example demonstrating how to retrieve fields vardefs from the accounts module with the get_module_fields method using cURL and the v4_1 REST API.
This example will only retrieve the vardefs for the 'id' and 'name' fields.
Example
<?php
$url = "http://{site_url}/service/v4_1/rest.php";
$username = "admin";
$password = "password";
function call($method, $parameters, $url)
{
ob_start();
$curl_request = curl_init();
curl_setopt($curl_request, CURLOPT_URL, $url); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Fields_From_a_Module/index.html |
7317680883b0-1 | curl_setopt($curl_request, CURLOPT_POST, 1);
curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($curl_request, CURLOPT_HEADER, 1);
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);
$jsonEncodedData = json_encode($parameters);
$post = array(
"method" => $method,
"input_type" => "JSON", | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Fields_From_a_Module/index.html |
7317680883b0-2 | "method" => $method,
"input_type" => "JSON",
"response_type" => "JSON",
"rest_data" => $jsonEncodedData
);
curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($curl_request);
curl_close($curl_request);
$result = explode("\r\n\r\n", $result, 2);
$response = json_decode($result[1]);
ob_end_flush();
return $response;
}
//login ----------------------------------------
$login_parameters = array(
"user_auth" => array(
"user_name" => $username,
"password" => md5($password), | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Fields_From_a_Module/index.html |
7317680883b0-3 | "password" => md5($password),
"version" => "1"
),
"application_name" => "RestTest",
"name_value_list" => array(),
);
$login_result = call("login", $login_parameters, $url);
/*
echo "<pre>";
print_r($login_result);
echo "</pre>";
*/
//get session id
$session_id = $login_result->id;
//retrieve fields --------------------------------
$get_module_fields_parameters = array(
//session id
'session' => $session_id,
//The name of the module from which to retrieve records
'module_name' => 'Accounts', | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Fields_From_a_Module/index.html |
7317680883b0-4 | 'module_name' => 'Accounts',
//Optional. Returns vardefs for the specified fields. An empty array will return all fields.
'fields' => array(
'id',
'name',
),
);
$get_module_fields_result = call("get_module_fields", $get_module_fields_parameters, $url);
echo "<pre>";
print_r($get_module_fields_result);
echo "</pre>";
?>
Result
stdClass Object
(
[module_name] => Accounts
[table_name] => accounts
[module_fields] => stdClass Object
(
[id] => stdClass Object
(
[name] => id
[type] => id
[group] => | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Fields_From_a_Module/index.html |
7317680883b0-5 | [type] => id
[group] =>
[id_name] =>
[label] => ID
[required] => 1
[options] => Array
(
)
[related_module] =>
[calculated] =>
[len] =>
)
[name] => stdClass Object
(
[name] => name
[type] => name
[group] =>
[id_name] =>
[label] => Name:
[required] => 1
[options] => Array
(
)
[related_module] =>
[calculated] =>
[len] => 150
)
)
[link_fields] => Array
(
)
)
 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Fields_From_a_Module/index.html |
7317680883b0-6 | [link_fields] => Array
(
)
)
Â
Last modified: 2023-02-03 21:09:36 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_a_List_of_Fields_From_a_Module/index.html |
2c9f22812545-0 | This API has been succeeded by a new version. It is recommended to upgrade to the latest API.
Creating Notes with Attachments
Overview
A PHP example demonstrating how to create a note using set_entry and add an attachment with the set_note_attachment method using cURL and the v4_1 REST API.
Example
<?php
$url = "http://{site_url}/service/v4_1/rest.php";
$username = "admin";
$password = "password";
//function to make cURL request
function call($method, $parameters, $url)
{
ob_start();
$curl_request = curl_init();
curl_setopt($curl_request, CURLOPT_URL, $url); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_Notes_with_Attachments/index.html |
2c9f22812545-1 | curl_setopt($curl_request, CURLOPT_POST, 1);
curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($curl_request, CURLOPT_HEADER, 1);
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);
$jsonEncodedData = json_encode($parameters);
$post = array(
"method" => $method,
"input_type" => "JSON", | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_Notes_with_Attachments/index.html |
2c9f22812545-2 | "method" => $method,
"input_type" => "JSON",
"response_type" => "JSON",
"rest_data" => $jsonEncodedData
);
curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($curl_request);
curl_close($curl_request);
$result = explode("\r\n\r\n", $result, 2);
$response = json_decode($result[1]);
ob_end_flush();
return $response;
}
//login ----------------------------------------------------
$login_parameters = array(
"user_auth" => array(
"user_name" => $username,
"password" => md5($password), | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_Notes_with_Attachments/index.html |
2c9f22812545-3 | "password" => md5($password),
"version" => "1"
),
"application_name" => "RestTest",
"name_value_list" => array(),
);
$login_result = call("login", $login_parameters, $url);
/*
echo "<pre>";
print_r($login_result);
echo "</pre>";
*/
//get session id
$session_id = $login_result->id;
//create note -----------------------------------------------
$set_entry_parameters = array(
//session id
"session" => $session_id,
//The name of the module
"module_name" => "Notes",
//Record attributes
"name_value_list" => array( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_Notes_with_Attachments/index.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.