id
stringlengths
14
16
text
stringlengths
33
5.27k
source
stringlengths
105
270
2c9f22812545-4
//Record attributes "name_value_list" => array( //to update a record, you will nee to pass in a record id as commented below //array("name" => "id", "value" => "9b170af9-3080-e22b-fbc1-4fea74def88f"), array("name" => "name", "value" => "Example Note"), ), ); $set_entry_result = call("set_entry", $set_entry_parameters, $url); echo "<pre>"; print_r($set_entry_result); echo "</pre>"; $note_id = $set_entry_result->id; //create note attachment --------------------------------------
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-5
//create note attachment -------------------------------------- $contents = file_get_contents ("/path/to/example_file.php"); $set_note_attachment_parameters = array( //session id "session" => $session_id, //The attachment details "note" => array( //The ID of the note containing the attachment. 'id' => $note_id, //The file name of the attachment. 'filename' => 'example_file.php', //The binary contents of the file. 'file' => base64_encode($contents), ), ); $set_note_attachment_result = call("set_note_attachment", $set_note_attachment_parameters, $url); echo "<pre>";
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-6
echo "<pre>"; print_r($set_note_attachment_result); echo "</pre>"; ?> Result //set_entry result stdClass Object ( [id] => 72508938-db19-3b5c-b7a8-50abc7ec3fdb [entry_list] => stdClass Object ( [name] => stdClass Object ( [name] => name [value] => Example Note ) ) ) //set_note_attachment result stdClass Object ( [id] => 72508938-db19-3b5c-b7a8-50abc7ec3fdb ) 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_Notes_with_Attachments/index.html
72707cba413f-0
This API has been succeeded by a new version. It is recommended to upgrade to the latest API. Retrieving Multiple Records by ID Overview A PHP example demonstrating how to retrieve multiple records from the accounts module with the get_entries method using cURL and the v4_1 REST API. This example will only retrieve 2 records and return the following fields: 'name', 'billing_address_state' and 'billing_address_country'. 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/Retrieving_Multiple_Records_by_ID/index.html
72707cba413f-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/Retrieving_Multiple_Records_by_ID/index.html
72707cba413f-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 --------------------------------------------- $login_parameters = array( "user_auth" => array(
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Multiple_Records_by_ID/index.html
72707cba413f-3
$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; //retrieve records ----------------------------------- $get_entries_parameters = array( //session id 'session' => $session_id,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Multiple_Records_by_ID/index.html
72707cba413f-4
//session id 'session' => $session_id, //The name of the module from which to retrieve records 'module_name' => 'Accounts', //An array of SugarBean IDs 'ids' => array( '20328809-9d0a-56fc-0e7c-4f7cb6eb1c83', '328b22a6-d784-66d9-0295-4f7cb59e8cbb', ), //Optional. The list of fields to be returned in the results 'select_fields' => array( 'name', 'billing_address_state', 'billing_address_country' ), //A list of link names and the fields to be returned for each link name
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Multiple_Records_by_ID/index.html
72707cba413f-5
//A list of link names and the fields to be returned for each link name 'link_name_to_fields_array' => array( ), ); $get_entries_result = call("get_entries", $get_entries_parameters, $url); echo "<pre>"; print_r($get_entries_result); echo "</pre>"; ?> Result stdClass Object ( [entry_list] => Array ( [0] => stdClass Object ( [id] => 20328809-9d0a-56fc-0e7c-4f7cb6eb1c83 [module_name] => Accounts [name_value_list] => stdClass Object ( [name] => stdClass Object
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Retrieving_Multiple_Records_by_ID/index.html
72707cba413f-6
( [name] => stdClass Object ( [name] => name [value] => Jungle Systems Inc ) [billing_address_state] => stdClass Object ( [name] => billing_address_state [value] => NY ) [billing_address_country] => stdClass Object ( [name] => billing_address_country [value] => USA ) ) ) [1] => stdClass Object ( [id] => 328b22a6-d784-66d9-0295-4f7cb59e8cbb [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_Multiple_Records_by_ID/index.html
72707cba413f-7
[name_value_list] => stdClass Object ( [name] => stdClass Object ( [name] => name [value] => Riviera Hotels ) [billing_address_state] => stdClass Object ( [name] => billing_address_state [value] => CA ) [billing_address_country] => stdClass Object ( [name] => billing_address_country [value] => USA ) ) ) ) [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_Multiple_Records_by_ID/index.html
e2df612cb8c8-0
This API has been succeeded by a new version. It is recommended to upgrade to the latest API. Relating Quotes and Products Overview A PHP example demonstrating how to create and relate Products to Quotes 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/Relating_Quotes_and_Products/index.html
e2df612cb8c8-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/Relating_Quotes_and_Products/index.html
e2df612cb8c8-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/Relating_Quotes_and_Products/index.html
e2df612cb8c8-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 quote ---------------------------------------------- $createQuoteParams = array( 'session' => $session_id, 'module_name' => 'Quotes', 'name_value_list' => array( array( 'name' => 'name', 'value' => 'Widget Quote' ), array( 'name' => 'team_count',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Relating_Quotes_and_Products/index.html
e2df612cb8c8-4
), array( 'name' => 'team_count', 'value' => '' ), array( 'name' => 'team_name', 'value' => '' ), array( 'name' => 'date_quote_expected_closed', 'value' => date('Y-m-d', mktime(0, 0, 0, date('m') , date('d')+7, date('Y'))) ), array( 'name' => 'quote_stage', 'value' => 'Negotiation' ), array( 'name' => 'quote_num', 'value' => '' ), array( 'name' => 'quote_type', 'value' => 'Quotes' ), array(
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Relating_Quotes_and_Products/index.html
e2df612cb8c8-5
'value' => 'Quotes' ), array( 'name' => 'subtotal', 'value' => '1230.23' ), array( 'name' => 'subtotal_usdollar', 'value' => '1230.23' ), ), ); $createQuoteResult = call('set_entry', $createQuoteParams, $url); echo "Create Quote Result<br />"; echo "<pre>"; print_r($createQuoteResult); echo "</pre>"; //create product ---------------------------------------------- $createProductParams = array( 'session' => $session_id, 'module_name' => 'Products', 'name_value_list' => array( array(
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Relating_Quotes_and_Products/index.html
e2df612cb8c8-6
'name_value_list' => array( array( 'name' => 'name', 'value' => 'Widget' ), array( 'name' => 'quote_id', 'value' => $createQuoteResult->id ), array( 'name' => 'status', 'value' => 'Quotes' ) ) ); $createProductResult = call('set_entry', $createProductParams, $url); echo "Create Product Result<br />"; echo "<pre>"; print_r($createProductResult); echo "</pre>"; //create product-bundle ---------------------------------------------- $createProductBundleParams = array( "session" => $session_id,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Relating_Quotes_and_Products/index.html
e2df612cb8c8-7
"session" => $session_id, "module_name" => "ProductBundles", "name_value_list" => array( array( 'name' => 'name', 'value' => 'Rest SugarOnline Order'), array( 'name' => 'bundle_stage', 'value' => 'Draft' ), array( 'name' => 'tax', 'value' => '0.00' ), array( 'name' => 'total', 'value' => '0.00' ), array( 'name' => 'subtotal', 'value' => '0.00' ), array( 'name' => 'shippint', 'value' => '0.00'
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Relating_Quotes_and_Products/index.html
e2df612cb8c8-8
'value' => '0.00' ), array( 'name' => 'currency_id', 'value' => '-99' ), ) ); $createProductBundleResult = call('set_entry', $createProductBundleParams, $url); echo "Create ProductBundles Result<br />"; echo "<pre>"; print_r($createProductBundleResult); echo "</pre>"; //relate product to product-bundle ---------------------------------------- $relationshipProductBundleProductsParams = array( 'sesssion' => $session_id, 'module_name' => 'ProductBundles', 'module_id' => $createProductBundleResult->id,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Relating_Quotes_and_Products/index.html
e2df612cb8c8-9
'module_id' => $createProductBundleResult->id, 'link_field_name' => 'products', 'related_ids' => array( $createProductResult->id ), ); // set the product bundles products relationship $relationshipProductBundleProductResult = call('set_relationship', $relationshipProductBundleProductsParams, $url); echo "Create ProductBundleProduct Relationship Result<br />"; echo "<pre>"; print_r($relationshipProductBundleProductResult); echo "</pre>"; //relate product-bundle to quote ---------------------------------------- $relationshipProductBundleQuoteParams = array( 'sesssion' => $session_id, 'module_name' => 'Quotes',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Relating_Quotes_and_Products/index.html
e2df612cb8c8-10
'module_name' => 'Quotes', 'module_id' => $createQuoteResult->id, 'link_field_name' => 'product_bundles', 'related_ids' => array( $createProductBundleResult->id ), 'name_value_list' => array() ); // set the product bundles quotes relationship $relationshipProductBundleQuoteResult = call('set_relationship', $relationshipProductBundleQuoteParams, $url); echo "Create ProductBundleQuote Relationship Result<br />"; echo "<pre>"; print_r($relationshipProductBundleQuoteResult); echo "</pre>"; Result //Create Quote Result stdClass Object (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Relating_Quotes_and_Products/index.html
e2df612cb8c8-11
Result //Create Quote Result stdClass Object ( [id] => 2e0cd18b-21da-50f0-10f6-517e835a1e09 [entry_list] => stdClass Object ( [name] => stdClass Object ( [name] => name [value] => Widget Quote ) [team_count] => stdClass Object ( [name] => team_count [value] => ) [team_name] => stdClass Object ( [name] => team_name [value] => ) [date_quote_expected_closed] => stdClass Object ( [name] => date_quote_expected_closed [value] => 2013-05-06 )
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Relating_Quotes_and_Products/index.html
e2df612cb8c8-12
[value] => 2013-05-06 ) [quote_stage] => stdClass Object ( [name] => quote_stage [value] => Negotiation ) [quote_num] => stdClass Object ( [name] => quote_num [value] => ) [quote_type] => stdClass Object ( [name] => quote_type [value] => Quotes ) [subtotal] => stdClass Object ( [name] => subtotal [value] => 1230.23 ) [subtotal_usdollar] => stdClass Object ( [name] => subtotal_usdollar [value] => 1230.23 ) ) ) //Create Product Result
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Relating_Quotes_and_Products/index.html
e2df612cb8c8-13
) ) ) //Create Product Result stdClass Object ( [id] => 6c40f344-a269-d4d0-9929-517e83884fb2 [entry_list] => stdClass Object ( [name] => stdClass Object ( [name] => name [value] => Widget ) [quote_id] => stdClass Object ( [name] => quote_id [value] => 2e0cd18b-21da-50f0-10f6-517e835a1e09 ) [status] => stdClass Object ( [name] => status [value] => Quotes ) ) ) //Create ProductBundles Result stdClass Object (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Relating_Quotes_and_Products/index.html
e2df612cb8c8-14
) ) //Create ProductBundles Result stdClass Object ( [id] => a8a4e449-7e72-dea5-9495-517e830a7353 [entry_list] => stdClass Object ( [name] => stdClass Object ( [name] => name [value] => Rest SugarOnline Order ) [bundle_stage] => stdClass Object ( [name] => bundle_stage [value] => Draft ) [tax] => stdClass Object ( [name] => tax [value] => 0 ) [total] => stdClass Object ( [name] => total [value] => 0 ) [subtotal] => stdClass Object (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Relating_Quotes_and_Products/index.html
e2df612cb8c8-15
) [subtotal] => stdClass Object ( [name] => subtotal [value] => 0 ) [currency_id] => stdClass Object ( [name] => currency_id [value] => -99 ) ) ) //Create ProductBundleProduct Relationship Result stdClass Object ( [created] => 1 [failed] => 0 [deleted] => 0 ) //Create ProductBundleQuote Relationship Result stdClass Object ( [created] => 1 [failed] => 0 [deleted] => 0 )   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/Relating_Quotes_and_Products/index.html
168046b1ed3f-0
This API has been succeeded by a new version. It is recommended to upgrade to the latest API. Creating or Updating a Record Overview A PHP example demonstrating how to create or update an Account with the set_entry 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_or_Updating_a_Record/index.html
168046b1ed3f-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_or_Updating_a_Record/index.html
168046b1ed3f-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_or_Updating_a_Record/index.html
168046b1ed3f-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 account ------------------------------------- $set_entry_parameters = array( //session id "session" => $session_id, //The name of the module from which to retrieve records. "module_name" => "Accounts", //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_or_Updating_a_Record/index.html
168046b1ed3f-4
//Record attributes "name_value_list" => array( //to update a record, you will nee to pass in a record id as commented below //array("name" => "id", "value" => "9b170af9-3080-e22b-fbc1-4fea74def88f"), array("name" => "name", "value" => "Test Account"), ), ); $set_entry_result = call("set_entry", $set_entry_parameters, $url); echo "<pre>"; print_r($set_entry_result); echo "</pre>"; ?> Result stdClass Object ( [id] => 9b170af9-3080-e22b-fbc1-4fea74def88f
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_or_Updating_a_Record/index.html
168046b1ed3f-5
[entry_list] => stdClass Object ( [name] => stdClass Object ( [name] => name [value] => Test Account ) ) ) 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_a_Record/index.html
1598546d2abf-0
This API has been succeeded by a new version. It is recommended to upgrade to the latest API. Creating or Updating Multiple Records Overview A PHP example demonstrating how to create or update multiple contacts with the set_entries 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_or_Updating_Multiple_Records/index.html
1598546d2abf-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_or_Updating_Multiple_Records/index.html
1598546d2abf-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_or_Updating_Multiple_Records/index.html
1598546d2abf-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 contacts ------------------------------------ $set_entries_parameters = array( //session id "session" => $session_id, //The name of the module from which to retrieve records. "module_name" => "Contacts", //Record attributes "name_value_list" => array( array(
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_or_Updating_Multiple_Records/index.html
1598546d2abf-4
"name_value_list" => array( array( //to update a record, you will nee to pass in a record id as commented below //array("name" => "id", "value" => "912e58c0-73e9-9cb6-c84e-4ff34d62620e"), array("name" => "first_name", "value" => "John"), array("name" => "last_name", "value" => "Smith"), ), array( //to update a record, you will nee to pass in a record id as commented below //array("name" => "id", "value" => "99d6ddfd-7d52-d45b-eba8-4ff34d684964"),
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_or_Updating_Multiple_Records/index.html
1598546d2abf-5
array("name" => "first_name", "value" => "Jane"), array("name" => "last_name", "value" => "Doe"), ), ), ); $set_entries_result = call("set_entries", $set_entries_parameters, $url); echo "<pre>"; print_r($set_entries_result); echo "</pre>"; ?> Result stdClass Object ( [ids] => Array ( [0] => 912e58c0-73e9-9cb6-c84e-4ff34d62620e [1] => 99d6ddfd-7d52-d45b-eba8-4ff34d684964 ) ) Â
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Creating_or_Updating_Multiple_Records/index.html
1598546d2abf-6
) )   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_Multiple_Records/index.html
3bc6ca952158-0
This API has been succeeded by a new version. It is recommended to upgrade to the latest API. Searching Records Overview A PHP example demonstrating how to search the accounts module with the search_by_module method using cURL and the v4_1 REST API. This script will return two results, sorted by the id field, and return the value of the id, name, account_type, phone_office, and assigned_user_name fields. 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/Searching_Records/index.html
3bc6ca952158-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/Searching_Records/index.html
3bc6ca952158-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 ----------------------------------------- $login_parameters = array( "user_auth" => array(
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Searching_Records/index.html
3bc6ca952158-3
$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 --------------------------------------- $search_by_module_parameters = array( //Session id "session" => $session_id, //The string to search for.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Searching_Records/index.html
3bc6ca952158-4
"session" => $session_id, //The string to search for. 'search_string' => 'Customer', //The list of modules to query. 'modules' => array( 'Accounts', ), //The record offset from which to start. 'offset' => 0, //The maximum number of records to return. 'max_results' => 2, //Filters records by the assigned user ID. //Leave this empty if no filter should be applied. 'id' => '', //An array of fields to return. //If empty the default return fields will be from the active listviewdefs. 'select_fields' => array( 'id', 'name', 'account_type', 'phone_office',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Searching_Records/index.html
3bc6ca952158-5
'name', 'account_type', 'phone_office', 'assigned_user_name', ), //If the search is to only search modules participating in the unified search. //Unified search is the SugarCRM Global Search alternative to Full-Text Search. 'unified_search_only' => false, //If only records marked as favorites should be returned. 'favorites' => false ); $search_by_module_result = call('search_by_module', $search_by_module_parameters, $url); echo '<pre>'; print_r($search_by_module_result); echo '</pre>'; ?> Result stdClass Object ( [result_count] => 2 [total_count] => 200
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Searching_Records/index.html
3bc6ca952158-6
( [result_count] => 2 [total_count] => 200 [next_offset] => 2 [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 )
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Searching_Records/index.html
3bc6ca952158-7
[value] => Bernie Worthey ) [title] => stdClass Object ( [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 (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/Legacy_API/REST/PHP/Searching_Records/index.html
3bc6ca952158-8
) [name] => stdClass Object ( [name] => name [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/Searching_Records/index.html
496f6ad357f5-0
REST API Examples of integrating with Sugar REST APIs. TopicsBashBash cURL examples of integrating with the REST v11 API.PHPPHP Examples interacting with the v11 REST API. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/index.html
921b9b40d5e7-0
Bash Bash cURL examples of integrating with the REST v11 API.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/index.html
921b9b40d5e7-1
TopicsHow to Export a List of RecordsAn example in bash script demonstrating how to export a list of records using the v11 /<module>/export/:record_list_id REST GET endpoint.How to Filter a List of RecordsAn example in bash script demonstrating how to filter records using the v11 /<module>/filter REST POST endpoints.How to Favorite a RecordAn example in bash script demonstrating how to favorite a record using the v11 <module>/:record/favorite REST PUT API endpoint.How to Manipulate File AttachmentsAn example in bash script demonstrating how to attach a file to a record using the v11 <module>/:record/file/:field REST POST API endpoint, then retrieve it with the GET endpoint.How to Fetch Related RecordsAn example in bash script demonstrating how to fetch related records using the v11 /<module>/:record/link/:link REST GET endpoints.How to
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/index.html
921b9b40d5e7-2
/<module>/:record/link/:link REST GET endpoints.How to Manipulate Records (CRUD)The following page will provide examples in bash script demonstrating how to use the CRUD (Create, Read, Update, Delete) endpoints in the REST v11 API.How to Follow a RecordAn example in bash script demonstrating how to follow a record using the v11 /<module>/:record/subscribe REST POST endpoint.How to Unfavorite a RecordAn example in bash script demonstrating how to unfavorite a record using the v11 /<module>/:record/unfavorite REST PUT endpoint.How to Unfollow a RecordAn example in bash script demonstrating how to unfollow a record using the v11 /<module>/:record/unsubscribe REST DELETE endpoint.How to Get the Most Active UsersAn example in bash script demonstrating how to fetch the most active users for meetings, calls, inbound emails, and
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/index.html
921b9b40d5e7-3
bash script demonstrating how to fetch the most active users for meetings, calls, inbound emails, and outbound emails using the v11 /mostactiveusers REST GET endpoint.How to Authenticate and Log OutAn example in bash script on how to authenticate and logout of the v11 REST API using the /oauth2/token and /oauth2/logout POST endpoints.How to PingAn example in bash script demonstrating how to ping using the REST v11 /ping GET endpoint.How to Fetch the Current Users TimeAn example in bash script demonstrating how to fetch the current users time with the v11 /ping/whattimeisit REST GET endpoint.How to Fetch Recently Viewed RecordsAn example in bash script demonstrating how to retrieve recently viewed records using the v11 /recent REST GET endpoint.How to Use the Global SearchAn example in bash script demonstrating how to globally search for records using the REST v11 /search GET endpoint.How to
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/index.html
921b9b40d5e7-4
script demonstrating how to globally search for records using the REST v11 /search GET endpoint.How to Check for Duplicate RecordsAn example in bash script demonstrating how to check for duplicate records using the v11 /<module>/duplicateCheck REST POST endpoint.How to Manipulate QuotesA Bash example demonstrating how to manipulate Quotes and related record data such as ProductBundles, Products, and ProductBundleNotes.How to Manipulate Tags (CRUD)The following page will provide examples of bash script demonstrating how to use the CRUD (Create, Read, Update, Delete) endpoints for tags in the REST v11 API.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/index.html
921b9b40d5e7-5
Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/index.html
d0af5de49333-0
How to Fetch Recently Viewed Records Overview An example in bash script demonstrating how to retrieve recently viewed records using the v11 /recent REST GET endpoint. Authenticating First, you will need to authenticate to the Sugar API. An example is shown below: curl -X POST -H Cache-Control:no-cache -H "Content-Type: application/json" -d '{ "grant_type":"password", "client_id":"sugar", "client_secret":"", "username":"admin", "password":"password", "platform":"custom_api" }' https://{site_url}/rest/v11/oauth2/token More information on authenticating can be found in the How to Authenticate and Log Out example and /oauth2/logout endpoint documentation. Recently Viewed Records
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-1
Recently Viewed Records Next, we will need to identify the records we want to see using the /recent endpoint. In this case, we are going to request Accounts, Contacts and Leads. curl -s -X GET -H OAuth-Token:{access_token} -H Cache-Control:no-cache https://{site_url}/rest/v11/recent?module_list=Accounts%2CContacts%2CLeads More information on the search API can be found in the /recent documentation. Response The data received from the server is shown below: { "next_offset":-1, "records":[ { "my_favorite":false, "following":false, "id":"f3951f4d-2d17-7939-c5ec-56fedbb9e92f",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-2
"name":"Talia Knupp", "date_entered":"2016-04-01T15:34:00-05:00", "date_modified":"2016-04-06T10:33:24-05:00", "modified_user_id":"1", "modified_by_name":"Administrator", "created_by":"1", "created_by_name":"Administrator", "doc_owner":"", "user_favorites":"", "description":"", "deleted":false, "assigned_user_id":"seed_will_id", "assigned_user_name":"Will Westin", "team_count":"", "team_name":[ { "id":"East", "name":"East",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-3
{ "id":"East", "name":"East", "name_2":"", "primary":true }, { "id":"West", "name":"West", "name_2":"", "primary":false } ], "email":[ { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":true, "reply_to_address":false }, { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":false, "reply_to_address":false } ],
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-4
"reply_to_address":false } ], "email1":"[email protected]", "email2":"[email protected]", "invalid_email":false, "email_opt_out":false, "email_addresses_non_primary":"", "salutation":"", "first_name":"Talia", "last_name":"Knupp", "full_name":"Talia Knupp", "title":"Senior Product Manager", "facebook":"", "twitter":"", "googleplus":"", "department":"", "do_not_call":false, "phone_home":"(963) 741-3689", "phone_mobile":"(600) 831-9872",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-5
"phone_mobile":"(600) 831-9872", "phone_work":"(680) 991-2837", "phone_other":"", "phone_fax":"", "primary_address_street":"111 Silicon Valley Road", "primary_address_street_2":"", "primary_address_street_3":"", "primary_address_city":"Sunnyvale", "primary_address_state":"NY", "primary_address_postalcode":"99452", "primary_address_country":"USA", "alt_address_street":"", "alt_address_street_2":"", "alt_address_street_3":"", "alt_address_city":"", "alt_address_state":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-6
"alt_address_city":"", "alt_address_state":"", "alt_address_postalcode":"", "alt_address_country":"", "assistant":"", "assistant_phone":"", "picture":"", "converted":false, "refered_by":"", "lead_source":"Word of mouth", "lead_source_description":"", "status":"In Process", "status_description":"", "reports_to_id":"", "report_to_name":"", "dnb_principal_id":"", "account_name":"First National S\/B", "account_description":"", "contact_id":"", "contact_name":"", "account_id":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-7
"contact_name":"", "account_id":"", "opportunity_id":"", "opportunity_name":"", "opportunity_amount":"", "campaign_id":"", "campaign_name":"", "c_accept_status_fields":"", "m_accept_status_fields":"", "accept_status_id":"", "accept_status_name":"", "accept_status_calls":"", "accept_status_meetings":"", "webtolead_email1":[ { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":true, "reply_to_address":false }, {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-8
"reply_to_address":false }, { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":false, "reply_to_address":false } ], "webtolead_email2":[ { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":true, "reply_to_address":false }, { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":false,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-9
"opt_out":false, "primary_address":false, "reply_to_address":false } ], "webtolead_email_opt_out":"", "webtolead_invalid_email":"", "birthdate":"", "portal_name":"", "portal_app":"", "website":"", "preferred_language":"", "mkto_sync":false, "mkto_id":null, "mkto_lead_score":null, "fruits_c":"Apples", "_acl":{ "fields":{ } }, "_module":"Leads", "_last_viewed_date":"2016-04-06T10:33:24-05:00" },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-10
}, { "my_favorite":false, "following":false, "id":"e8c641ca-1b8c-74c1-d08d-56fedbdd3187", "name":"MTM Investment Bank F S B", "date_entered":"2016-04-01T15:34:00-05:00", "date_modified":"2016-04-06T10:16:52-05:00", "modified_user_id":"1", "modified_by_name":"Administrator", "created_by":"1", "created_by_name":"Administrator", "doc_owner":"", "user_favorites":"", "description":"", "deleted":false,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-11
"description":"", "deleted":false, "assigned_user_id":"seed_will_id", "assigned_user_name":"Will Westin", "team_count":"", "team_name":[ { "id":"East", "name":"East", "name_2":"", "primary":true }, { "id":"West", "name":"West", "name_2":"", "primary":false } ], "email":[ { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":true, "reply_to_address":false }, {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-12
"reply_to_address":false }, { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":false, "reply_to_address":false } ], "email1":"[email protected]", "email2":"[email protected]", "invalid_email":false, "email_opt_out":false, "email_addresses_non_primary":"", "facebook":"", "twitter":"", "googleplus":"", "account_type":"Customer", "industry":"a", "annual_revenue":"", "phone_fax":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-13
"annual_revenue":"", "phone_fax":"", "billing_address_street":"67321 West Siam St.", "billing_address_street_2":"", "billing_address_street_3":"", "billing_address_street_4":"", "billing_address_city":"Alabama", "billing_address_state":"NY", "billing_address_postalcode":"52272", "billing_address_country":"USA", "rating":"", "phone_office":"(012) 704-8075", "phone_alternate":"", "website":"www.salesqa.it", "ownership":"", "employees":"", "ticker_symbol":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-14
"employees":"", "ticker_symbol":"", "shipping_address_street":"67321 West Siam St.", "shipping_address_street_2":"", "shipping_address_street_3":"", "shipping_address_street_4":"", "shipping_address_city":"Alabama", "shipping_address_state":"NY", "shipping_address_postalcode":"52272", "shipping_address_country":"USA", "parent_id":"", "sic_code":"", "duns_num":"", "parent_name":"", "campaign_id":"", "campaign_name":"", "_acl":{ "fields":{ } }, "_module":"Accounts",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-15
"fields":{ } }, "_module":"Accounts", "_last_viewed_date":"2016-04-06T10:16:52-05:00" }, { "my_favorite":false, "following":false, "id":"f31b2f00-468c-3d35-1e88-56fedbd3921d", "name":"Kaycee Gibney", "date_entered":"2016-04-01T15:34:00-05:00", "date_modified":"2016-04-06T10:16:24-05:00", "modified_user_id":"1", "modified_by_name":"Administrator", "created_by":"1",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-16
"created_by":"1", "created_by_name":"Administrator", "doc_owner":"", "user_favorites":"", "description":"", "deleted":false, "assigned_user_id":"seed_jim_id", "assigned_user_name":"Jim Brennan", "team_count":"", "team_name":[ { "id":"East", "name":"East", "name_2":"", "primary":true } ], "email":[ { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":true, "reply_to_address":false },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-17
"reply_to_address":false }, { "email_address":"[email protected]", "invalid_email":false, "opt_out":true, "primary_address":false, "reply_to_address":false } ], "email1":"[email protected]", "email2":"[email protected]", "invalid_email":false, "email_opt_out":false, "email_addresses_non_primary":"", "salutation":"", "first_name":"Kaycee", "last_name":"Gibney", "full_name":"Kaycee Gibney", "title":"Mgr Operations", "facebook":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-18
"title":"Mgr Operations", "facebook":"", "twitter":"", "googleplus":"", "department":"", "do_not_call":false, "phone_home":"(599) 165-2396", "phone_mobile":"(215) 591-9574", "phone_work":"(771) 945-3648", "phone_other":"", "phone_fax":"", "primary_address_street":"321 University Ave.", "primary_address_street_2":"", "primary_address_street_3":"", "primary_address_city":"Santa Monica", "primary_address_state":"NY", "primary_address_postalcode":"96154", "primary_address_country":"USA",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-19
"primary_address_country":"USA", "alt_address_street":"", "alt_address_street_2":"", "alt_address_street_3":"", "alt_address_city":"", "alt_address_state":"", "alt_address_postalcode":"", "alt_address_country":"", "assistant":"", "assistant_phone":"", "picture":"", "email_and_name1":"", "lead_source":"Existing Customer", "account_name":"Tracker Com LP", "account_id":"72ad6f00-e345-1cab-b370-56fedbd23deb", "dnb_principal_id":"", "opportunity_role_fields":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-20
"opportunity_role_fields":"", "opportunity_role_id":"", "opportunity_role":"", "reports_to_id":"", "report_to_name":"", "birthdate":"", "portal_name":"KayceeGibney33", "portal_active":true, "portal_password":true, "portal_password1":null, "portal_app":"", "preferred_language":"en_us", "campaign_id":"", "campaign_name":"", "c_accept_status_fields":"", "m_accept_status_fields":"", "accept_status_id":"", "accept_status_name":"", "accept_status_calls":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
d0af5de49333-21
"accept_status_calls":"", "accept_status_meetings":"", "sync_contact":false, "mkto_sync":false, "mkto_id":null, "mkto_lead_score":null, "_acl":{ "fields":{ } }, "_module":"Contacts", "_last_viewed_date":"2016-04-06T10:16:24-05:00" } ] } There are 3 records shown above, the _module field tells you if the record is from Accounts, Contacts or Leads.  The _last_viewed_date tells you when the record was last seen. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Recently_Viewed_Records/index.html
5f59290055f3-0
How to Manipulate Quotes Overview A Bash example demonstrating how to manipulate Quotes and related record data such as ProductBundles, Products, and ProductBundleNotes.  Manipulating Quotes Authenticating First, you will need to authenticate to the Sugar API. An example is shown below: curl -X POST -H Cache-Control:no-cache -H "Content-Type: application/json" -d '{ "grant_type":"password", "client_id":"sugar", "client_secret":"", "username":"admin", "password":"password", "platform":"custom_api" }' https://{site_url}/rest/v11/oauth2/token
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-1
More information on authenticating can be found in the How to Authenticate and Log Out example and /oauth2/logout endpoint documentation. Creating a Quote Once authenticated, we can submit a Quote record using the <module> endpoint. Since a Quote record is a sum of its parts (i.e. ProductBundles and Products) you can submit the related ProductBundles and Products in the same request payload using the relationship Links and the "create" property. curl -X POST -H OAuth-Token:<access_token> -H Cache-Control:no-cache -H "Content-Type: application/json" -d '{ "name": "Test Quote", "quote_stage": "Draft", "date_quote_expected_closed": "2017-06-12T11:51:57-0400",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-2
"product_bundles": { "create": [ { "name": "Product Bundle 1", "bundle_stage": "Draft", "currency_id": ":-99", "base_rate": "1.0", "shipping": "0.00", "products": { "create": [ { "tax_class": "Taxable", "quantity": 1000, "name": "Test Product 1", "description": "My Test Product", "mft_part_num": "mft100012021", "cost_price": "100.00", "list_price": "200.00", "discount_price": "175.00", "discount_amount": "0.00",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-3
"discount_amount": "0.00", "discount_select": 0, "product_template_id": "", "type_id": "", "status": "Quotes" } ] }, "product_bundle_notes": { "create": [ { "description": "Free shipping", "position": 1 } ] } }, { "name": "Product Bundle 2", "bundle_stage": "Draft", "currency_id": ":-99", "base_rate": "1.0", "shipping": "25.00", "products": { "create": [ { "quantity": 1000, "name": "Test Product 2",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-4
"quantity": 1000, "name": "Test Product 2", "description": "My Other Product", "mft_part_num": "mft100012234", "cost_price": "150.00", "list_price": "300.00", "discount_price": "275.00", "discount_amount": "0.00", "discount_select": 0, "product_template_id": "", "type_id": "", "status": "Quotes" }, { "quantity": 500, "name": "Test Product 3", "description": "My Other Other Product", "mft_part_num": "mft100012123", "cost_price": "10.00",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-5
"cost_price": "10.00", "list_price": "500.00", "discount_price": "400.00", "discount_amount": "0.00", "discount_select": 0, "product_template_id": "", "type_id": "", "status": "Quotes" } ] } } ] } }' http://<site_url>/rest/v11/Quotes Response The data received from the server is shown below: { "id": "ee1e1ae8-372a-11e7-8bf4-3c15c2c94fb0", "name": "Test Quote",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-6
"name": "Test Quote", "date_entered": "2017-05-12T11:51:57-04:00", "date_modified": "2017-05-12T11:51:57-04:00", "modified_user_id": "1", "modified_by_name": "Administrator", "modified_user_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": { "pwd_last_changed": { "write": "no", "create": "no" }, "last_login": { "write": "no", "create": "no" } }, "delete": "no",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-7
} }, "delete": "no", "_hash": "08b99a97c2e8d792f7a44d8882b5af6d" } }, "created_by": "1", "created_by_name": "Administrator", "created_by_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": { "pwd_last_changed": { "write": "no", "create": "no" }, "last_login": { "write": "no", "create": "no" } }, "delete": "no",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-8
} }, "delete": "no", "_hash": "08b99a97c2e8d792f7a44d8882b5af6d" } }, "description": "", "deleted": false, "shipper_id": "", "shipper_name": "", "shippers": { "name": "", "id": "", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "taxrate_id": "", "taxrate_name": "", "taxrates": { "name": "", "id": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-9
"name": "", "id": "", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "taxrate_value": "0.000000", "show_line_nums": true, "quote_type": "Quotes", "date_quote_expected_closed": "2017-06-12", "original_po_date": "", "payment_terms": "", "date_quote_closed": "", "date_order_shipped": "", "order_stage": "", "quote_stage": "Draft", "purchase_order_num": "", "quote_num": 2,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-10
"quote_num": 2, "subtotal": "650000.000000", "subtotal_usdollar": "650000.000000", "shipping": "0.000000", "shipping_usdollar": "0.000000", "discount": "", "deal_tot": "0.00", "deal_tot_discount_percentage": "0.00", "deal_tot_usdollar": "0.00", "new_sub": "650000.000000", "new_sub_usdollar": "650000.000000", "taxable_subtotal": "650000.000000", "tax": "0.000000", "tax_usdollar": "0.000000", "total": "650000.000000",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-11
"total": "650000.000000", "total_usdollar": "650000.000000", "billing_address_street": "", "billing_address_city": "", "billing_address_state": "", "billing_address_postalcode": "", "billing_address_country": "", "shipping_address_street": "", "shipping_address_city": "", "shipping_address_state": "", "shipping_address_postalcode": "", "shipping_address_country": "", "system_id": 1, "shipping_account_name": "", "shipping_accounts": { "name": "", "id": "", "_acl": {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-12
"name": "", "id": "", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "shipping_account_id": "", "shipping_contact_name": "", "shipping_contacts": { "full_name": "", "id": "", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" }, "last_name": "" }, "shipping_contact_id": "", "account_name": "", "billing_accounts": {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-13
"account_name": "", "billing_accounts": { "name": "", "id": "", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "account_id": "", "billing_account_name": "", "billing_account_id": "", "billing_contact_name": "", "billing_contacts": { "full_name": "", "id": "", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-14
}, "last_name": "" }, "billing_contact_id": "", "opportunity_name": "", "opportunities": { "name": "", "id": "", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "opportunity_id": "", "following": "", "my_favorite": false, "tag": [ ], "locked_fields": [ ], "assigned_user_id": "", "assigned_user_name": "", "assigned_user_link": { "full_name": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-15
"assigned_user_link": { "full_name": "", "id": "", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "team_count": "", "team_count_link": { "team_count": "", "id": "1", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "team_name": [ {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-16
} }, "team_name": [ { "id": "a0512788-3680-11e7-b42f-3c15c2c94fb0", "name": "Administrator", "name_2": "", "primary": false, "selected": false }, { "id": "1", "name": "Global", "name_2": "", "primary": true, "selected": false } ], "currency_id": "-99", "base_rate": "1.000000", "currency_name": "", "currencies": { "name": "", "id": "-99", "_acl": { "fields": [ ],
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-17
"_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" }, "symbol": "" }, "currency_symbol": "", "_acl": { "fields": { } }, "_module": "Quotes" } You might notice that the Response does not contain the related data. To view the related data use the <module>/<record_id>/link/<link_name> - GET Endpoint. Modifying the Quote's Product Bundles Once the quote is created, you might need to add or remove Product Bundles from the Quote. This can be done using the /<module>/<record> - PUT endpoint. //Create a new ProductBundle
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-18
//Create a new ProductBundle curl -X PUT -H OAuth-Token:<access_token> -H Cache-Control:no-cache -d '{ "product_bundles": { "delete": [ "<related_bundle_id>" ], "add": [ "<new_bundle_id>" ] } }' http://<site_url>/rest/v11/Quotes/<record_id>  The above script removes a previously related Product Bundle from the Quote and adds a different already created Product Bundle to the Quote Response Payload The response payload will match the standard /<module>/<record> - PUT Endpoint Response which is the entire values of the updated record. The previous Response for Creating the quote is the same as shown above.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
5f59290055f3-19
Last modified: 2023-02-03 21:09:36
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Quotes/index.html
f266afdfe155-0
How to Ping Overview An example in bash script demonstrating how to ping using the REST v11 /ping GET endpoint. Pinging Authenticating First, you will need to authenticate to the Sugar API. An example is shown below: curl -X POST -H Cache-Control:no-cache -H "Content-Type: application/json" -d '{ "grant_type":"password", "client_id":"sugar", "client_secret":"", "username":"admin", "password":"password", "platform":"custom_api" }' https://{site_url}/rest/v11/oauth2/token More information on authenticating can be found in the How to Authenticate and Log Out example and /oauth2/logout endpoint documentation. Pinging
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Ping/index.html
f266afdfe155-1
Pinging Once we have authenticated, we can now ping the system as shown below. curl -s -X GET -H OAuth-Token:{access_token} -H Cache-Control:no-cache https://{site_url}/rest/v11/ping More information on pinging can be found in the /ping documentation. Response "pong" Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Ping/index.html