id
stringlengths
14
16
text
stringlengths
33
5.27k
source
stringlengths
105
270
30601491f6ef-25
"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 will tell you when the record was last seen. Downloads You can download the full API example here
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-26
Downloads You can download the full API example here 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/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
86984e17682c-0
How to Manipulate Quotes Overview A PHP 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: <?php $instance_url = "http://{site_url}/rest/v11"; $username = "admin"; $password = "password"; //Login - POST /oauth2/token $auth_url = $instance_url . "/oauth2/token"; $oauth2_token_arguments = array( "grant_type" => "password", //client id - default is sugar. //It is recommended to create your own in Admin > OAuth Keys
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-1
//It is recommended to create your own in Admin > OAuth Keys "client_id" => "sugar", "client_secret" => "", "username" => $username, "password" => $password, //platform type - default is base. //It is recommend to change the platform to a custom name such as "custom_api" to avoid authentication conflicts. "platform" => "custom_api" ); $auth_request = curl_init($auth_url); curl_setopt($auth_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($auth_request, CURLOPT_HEADER, false); curl_setopt($auth_request, CURLOPT_SSL_VERIFYPEER, 0);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-2
curl_setopt($auth_request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($auth_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($auth_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json" )); //convert arguments to json $json_arguments = json_encode($oauth2_token_arguments); curl_setopt($auth_request, CURLOPT_POSTFIELDS, $json_arguments); //execute request $oauth2_token_response = curl_exec($auth_request); //decode oauth2 response to get token $oauth2_token_response_obj = json_decode($oauth2_token_response);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-3
$oauth_token = $oauth2_token_response_obj->access_token; 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. //Create Records - POST /<module> $url = $instance_url . "/Quotes"; //Set up the Record details $DateTime = new DateTime(); //Expected Close Date in 1 Month $DateTime->add(new DateInterval("P1M")); //Quote Record
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-4
//Quote Record $quote = array( 'name' => 'Test Quote', 'quote_stage' => 'Draft', 'date_quote_expected_closed' => $DateTime->format(DateTime::ISO8601), //Create Product Bundles 'product_bundles' => array( 'create' => array( array( "name" => "Product Bundle 1", "bundle_stage" => "Draft", "currency_id" => ":-99", "base_rate" => "1.0", "shipping" => "0.00", "products" => array( //Create Product in Bundle 1 "create" => array( array( "tax_class" => "Taxable", "quantity" => 1000.00,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-5
"quantity" => 1000.00, "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", "discount_select" => 0, "product_template_id" => "", "type_id" => "", "status" => "Quotes" ) ) ), //Create Product Bundle Note in Bundle 1
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-6
) ) ), //Create Product Bundle Note in Bundle 1 "product_bundle_notes" => array( "create" => array( array( "description" => "Free shipping", "position" => 1 ) ) ) ), array( "name" => "Product Bundle 2", "bundle_stage" => "Draft", "currency_id" => ":-99", "base_rate" => "1.0", "shipping" => "25.00", "products" => array( //Create Products in Bundle 2 "create" => array( array( "quantity" => 1000.00, "name" => "Test Product 2",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-7
"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" ), array( "quantity" => 500.00, "name" => "Test Product 3",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-8
"name" => "Test Product 3", "description" => "My Other Other Product", "mft_part_num" => "mft100012123", "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" ) ) ) ) ), ) ); $curl_request = curl_init($url);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-9
) ); $curl_request = curl_init($url); curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($curl_request, CURLOPT_HEADER, false); curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($curl_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "oauth-token: {$oauth_token}" ));
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-10
"oauth-token: {$oauth_token}" )); //convert arguments to json $json_arguments = json_encode($quote); curl_setopt($curl_request, CURLOPT_POSTFIELDS, $json_arguments); //execute request $curl_response = curl_exec($curl_request); //decode json $createdQuote = json_decode($curl_response); //display the created record print_r($createdQuote); curl_close($curl_request); Request Payload The data sent to the server is shown below: { "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/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-11
"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/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-12
"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/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-13
"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/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-14
"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" } ] } } ] } } Response The data received from the server is shown below: { "id": "ee1e1ae8-372a-11e7-8bf4-3c15c2c94fb0", "name": "Test Quote", "date_entered": "2017-05-12T11:51:57-04:00",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-15
"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", "_hash": "08b99a97c2e8d792f7a44d8882b5af6d" } },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-16
} }, "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", "_hash": "08b99a97c2e8d792f7a44d8882b5af6d" } }, "description": "", "deleted": false, "shipper_id": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-17
"deleted": false, "shipper_id": "", "shipper_name": "", "shippers": { "name": "", "id": "", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "taxrate_id": "", "taxrate_name": "", "taxrates": { "name": "", "id": "", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "taxrate_value": "0.000000",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-18
} }, "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, "subtotal": "650000.000000", "subtotal_usdollar": "650000.000000", "shipping": "0.000000", "shipping_usdollar": "0.000000",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-19
"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", "total_usdollar": "650000.000000", "billing_address_street": "", "billing_address_city": "", "billing_address_state": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-20
"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": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-21
} }, "shipping_account_id": "", "shipping_contact_name": "", "shipping_contacts": { "full_name": "", "id": "", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" }, "last_name": "" }, "shipping_contact_id": "", "account_name": "", "billing_accounts": { "name": "", "id": "", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17"
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-22
} }, "account_id": "", "billing_account_name": "", "billing_account_id": "", "billing_contact_name": "", "billing_contacts": { "full_name": "", "id": "", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" }, "last_name": "" }, "billing_contact_id": "", "opportunity_name": "", "opportunities": { "name": "", "id": "", "_acl": { "fields": [ ],
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-23
"_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "opportunity_id": "", "following": "", "my_favorite": false, "tag": [ ], "locked_fields": [ ], "assigned_user_id": "", "assigned_user_name": "", "assigned_user_link": { "full_name": "", "id": "", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-24
} }, "team_count": "", "team_count_link": { "team_count": "", "id": "1", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "team_name": [ { "id": "a0512788-3680-11e7-b42f-3c15c2c94fb0", "name": "Administrator", "name_2": "", "primary": false, "selected": false }, { "id": "1", "name": "Global", "name_2": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-25
"name": "Global", "name_2": "", "primary": true, "selected": false } ], "currency_id": "-99", "base_rate": "1.000000", "currency_name": "", "currencies": { "name": "", "id": "-99", "_acl": { "fields": [ ], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" }, "symbol": "" }, "currency_symbol": "", "_acl": { "fields": { } }, "_module": "Quotes" }
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-26
} }, "_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 $url = $instance_url . "/ProductBundles"; $productBundle = array( "name" => "Product Bundle 3", "bundle_stage" => "Draft", "currency_id" => ":-99", "base_rate" => "1.0",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-27
"base_rate" => "1.0", "shipping" => "0.00", "products" => array( //Create Product in Bundle 3 "create" => array( array( "tax_class" => "Taxable", "quantity" => 100.00, "name" => "Test Product 3", "description" => "Test Product 3", "mft_part_num" => "mft100012021", "cost_price" => "100.00", "list_price" => "250.00", "discount_price" => "175.00", "discount_amount" => "0.00", "discount_select" => 0, "product_template_id" => "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-28
"product_template_id" => "", "type_id" => "", "status" => "Quotes", "position" => 0 ) ) ), //Create Product Bundle Note in Bundle 3 "product_bundle_notes" => array( "create" => array( array( "description" => "Free shipping", "position" => 1 ) ) ) ); $curl_request = curl_init($url); curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($curl_request, CURLOPT_HEADER, false);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-29
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($curl_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "oauth-token: {$oauth_token}" )); //convert arguments to json $json_arguments = json_encode($productBundle); curl_setopt($curl_request, CURLOPT_POSTFIELDS, $json_arguments); //execute request $curl_response = curl_exec($curl_request);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-30
//execute request $curl_response = curl_exec($curl_request); //decode json $createdBundle = json_decode($curl_response); //display the created record print_r($createdBundle); curl_close($curl_request); //Add Bundle to Previously Created Quote //PUT to /Quotes/<record_id> $url = $instance_url . "/Quotes/".$createdQuote->id; $quote = array( 'product_bundles' => array( 'delete' => array( 'some_bundle_id' ), 'add' => array( $createdBundle->id ) ) ); $curl_request = curl_init($url);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-31
) ); $curl_request = curl_init($url); curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($curl_request, CURLOPT_HEADER, false); curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($curl_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "oauth-token: {$oauth_token}" ));
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-32
"oauth-token: {$oauth_token}" )); //convert arguments to json $json_arguments = json_encode($quote); curl_setopt($curl_request, CURLOPT_POSTFIELDS, $json_arguments); //PUT Request curl_setopt($curl_request, CURLOPT_CUSTOMREQUEST, "PUT"); //execute request $curl_response = curl_exec($curl_request); //decode json $updatedQuote = json_decode($curl_response); //display the updated quote record print_r($updatedQuote); curl_close($curl_request);  The above script removes a previously related Product Bundle from the Quote and adds the Product Bundle that was created before it in the script. Request Payload
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/index.html
86984e17682c-33
Request Payload The data sent to the server to alter the Quotes Product Bundles is shown below: { "product_bundles": { "delete": [ "some_bundle_id" ], "add": [ "803972ea-3741-11e7-8edc-3c15c2c94fb0" ] } } 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. Download You can download the full API example here. 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/PHP/How_to_Manipulate_Quotes/index.html
31cee1a0dc2f-0
How to Ping Overview A PHP example 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: <?php $instance_url = "http://{site_url}/rest/v11"; $username = "admin"; $password = "password"; //Login - POST /oauth2/token $auth_url = $instance_url . "/oauth2/token"; $oauth2_token_arguments = array( "grant_type" => "password", //client id - default is sugar. //It is recommended to create your own in Admin > OAuth Keys "client_id" => "sugar", "client_secret" => "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Ping/index.html
31cee1a0dc2f-1
"client_secret" => "", "username" => $username, "password" => $password, //platform type - default is base. //It is recommend to change the platform to a custom name such as "custom_api" to avoid authentication conflicts. "platform" => "custom_api" ); $auth_request = curl_init($auth_url); curl_setopt($auth_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($auth_request, CURLOPT_HEADER, false); curl_setopt($auth_request, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($auth_request, CURLOPT_RETURNTRANSFER, 1);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Ping/index.html
31cee1a0dc2f-2
curl_setopt($auth_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($auth_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json" )); //convert arguments to json $json_arguments = json_encode($oauth2_token_arguments); curl_setopt($auth_request, CURLOPT_POSTFIELDS, $json_arguments); //execute request $oauth2_token_response = curl_exec($auth_request); //decode oauth2 response to get token $oauth2_token_response_obj = json_decode($oauth2_token_response); $oauth_token = $oauth2_token_response_obj->access_token;
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Ping/index.html
31cee1a0dc2f-3
More information on authenticating can be found in the How to Authenticate and Log Out example and /oauth2/logout endpoint documentation. Pinging Once we have authenticated, we can now ping the system as shown below. //Ping - GET /ping $ping_url = $instance_url . "/ping"; $ping_request = curl_init($ping_url); curl_setopt($ping_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($ping_request, CURLOPT_HEADER, false); //needed to return file headers curl_setopt($ping_request, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ping_request, CURLOPT_RETURNTRANSFER, 1);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Ping/index.html
31cee1a0dc2f-4
curl_setopt($ping_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ping_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "oauth-token: {$oauth_token}" )); $ping_response = curl_exec($ping_request); More information on pinging can be found in the /ping documentation. Response "pong" Download You can download the full API example here. 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/PHP/How_to_Ping/index.html
61c990020f1e-0
How to Check for Duplicate Records Overview An PHP example demonstrating how to check for duplicate records using the v11 /<module>/duplicateCheck REST POST endpoint. Duplicate Records Authenticating First, you will need to authenticate to the Sugar API. An example is shown below: <?php $instance_url = "http://{site_url}/rest/v11"; $username = "admin"; $password = "password"; //Login - POST /oauth2/token $auth_url = $instance_url . "/oauth2/token"; $oauth2_token_arguments = array( "grant_type" => "password", //client id - default is sugar. //It is recommended to create your own in Admin > OAuth Keys
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-1
//It is recommended to create your own in Admin > OAuth Keys "client_id" => "sugar", "client_secret" => "", "username" => $username, "password" => $password, //platform type - default is base. //It is recommend to change the platform to a custom name such as "custom_api" to avoid authentication conflicts. "platform" => "custom_api" ); $auth_request = curl_init($auth_url); curl_setopt($auth_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($auth_request, CURLOPT_HEADER, false); curl_setopt($auth_request, CURLOPT_SSL_VERIFYPEER, 0);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-2
curl_setopt($auth_request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($auth_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($auth_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json" )); //convert arguments to json $json_arguments = json_encode($oauth2_token_arguments); curl_setopt($auth_request, CURLOPT_POSTFIELDS, $json_arguments); //execute request $oauth2_token_response = curl_exec($auth_request); //decode oauth2 response to get token $oauth2_token_response_obj = json_decode($oauth2_token_response);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-3
$oauth_token = $oauth2_token_response_obj->access_token; More information on authenticating can be found in the How to Authenticate and Log Out example and /oauth2/logout endpoint documentation. Retrieving Duplicates Next, we will need to identify the records that are duplicates using the /<module>/duplicateCheck endpoint. //Check for duplicate records - POST /<module>/duplicateCheck $url = $instance_url . "/Accounts/duplicateCheck"; //Set up the Record details $record = array( 'name' => 'Test Record', ); $curl_request = curl_init($url); curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-4
curl_setopt($curl_request, CURLOPT_HEADER, false); curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($curl_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "oauth-token: {$oauth_token}" )); //convert arguments to json $json_arguments = json_encode($record); curl_setopt($curl_request, CURLOPT_POSTFIELDS, $json_arguments);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-5
//execute request $curl_response = curl_exec($curl_request); //decode json $createdRecord = json_decode($curl_response); //display the created record print_r($createdRecord); curl_close($curl_request); More information on the filter API can be found in the /<module>/duplicateCheck documentation. Request Payload The data sent to the server is shown below: { "name":"Test Record" } Response The data received from the server is shown below: { "next_offset": -1, "records": [{ "id": "7f6ea7be-60d6-11e6-8885-a0999b033b33", "name": "Test Record",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-6
"name": "Test Record", "date_entered": "2016-08-12T14:48:25-07:00", "date_modified": "2016-08-12T14:48:25-07:00", "modified_user_id": "1", "modified_by_name": "Administrator", "modified_user_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": [], "delete": "no", "_hash": "8e11bf9be8f04daddee9d08d44ea891e" } }, "created_by": "1", "created_by_name": "Administrator", "created_by_link": {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-7
"created_by_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": [], "delete": "no", "_hash": "8e11bf9be8f04daddee9d08d44ea891e" } }, "description": "Test Data 1", "deleted": false, "facebook": "", "twitter": "", "googleplus": "", "account_type": "", "industry": "", "annual_revenue": "", "phone_fax": "", "billing_address_street": "", "billing_address_street_2": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-8
"billing_address_street_2": "", "billing_address_street_3": "", "billing_address_street_4": "", "billing_address_city": "", "billing_address_state": "", "billing_address_postalcode": "", "billing_address_country": "", "rating": "", "phone_office": "", "phone_alternate": "", "website": "", "ownership": "", "employees": "", "ticker_symbol": "", "shipping_address_street": "", "shipping_address_street_2": "", "shipping_address_street_3": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-9
"shipping_address_street_3": "", "shipping_address_street_4": "", "shipping_address_city": "", "shipping_address_state": "", "shipping_address_postalcode": "", "shipping_address_country": "", "parent_id": "", "sic_code": "", "duns_num": "", "parent_name": "", "member_of": { "name": "", "id": "", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "campaign_id": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-10
} }, "campaign_id": "", "campaign_name": "", "campaign_accounts": { "name": "", "id": "", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "following": true, "my_favorite": false, "tag": [], "assigned_user_id": "1", "assigned_user_name": "Administrator", "assigned_user_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": [], "delete": "no",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-11
"fields": [], "delete": "no", "_hash": "8e11bf9be8f04daddee9d08d44ea891e" } }, "team_count": "", "team_count_link": { "team_count": "", "id": "1", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "team_name": [{ "id": "1", "name": "Global", "name_2": "", "primary": true }], "email": [], "email1": "", "email2": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-12
"email1": "", "email2": "", "invalid_email": "", "email_opt_out": "", "email_addresses_non_primary": "", "_acl": { "fields": {} }, "_module": "Accounts", "duplicate_check_rank": 8 }, { "id": "868b4f16-60d6-11e6-bdfc-a0999b033b33", "name": "Test Record", "date_entered": "2016-08-12T14:48:37-07:00", "date_modified": "2016-08-12T14:48:37-07:00", "modified_user_id": "1",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-13
"modified_user_id": "1", "modified_by_name": "Administrator", "modified_user_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": [], "delete": "no", "_hash": "8e11bf9be8f04daddee9d08d44ea891e" } }, "created_by": "1", "created_by_name": "Administrator", "created_by_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": [], "delete": "no",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-14
"fields": [], "delete": "no", "_hash": "8e11bf9be8f04daddee9d08d44ea891e" } }, "description": "Test Data 2", "deleted": false, "facebook": "", "twitter": "", "googleplus": "", "account_type": "", "industry": "", "annual_revenue": "", "phone_fax": "", "billing_address_street": "", "billing_address_street_2": "", "billing_address_street_3": "", "billing_address_street_4": "", "billing_address_city": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-15
"billing_address_city": "", "billing_address_state": "", "billing_address_postalcode": "", "billing_address_country": "", "rating": "", "phone_office": "", "phone_alternate": "", "website": "", "ownership": "", "employees": "", "ticker_symbol": "", "shipping_address_street": "", "shipping_address_street_2": "", "shipping_address_street_3": "", "shipping_address_street_4": "", "shipping_address_city": "", "shipping_address_state": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-16
"shipping_address_state": "", "shipping_address_postalcode": "", "shipping_address_country": "", "parent_id": "", "sic_code": "", "duns_num": "", "parent_name": "", "member_of": { "name": "", "id": "", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "campaign_id": "", "campaign_name": "", "campaign_accounts": { "name": "", "id": "", "_acl": { "fields": [],
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-17
"id": "", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "following": true, "my_favorite": false, "tag": [], "assigned_user_id": "1", "assigned_user_name": "Administrator", "assigned_user_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": [], "delete": "no", "_hash": "8e11bf9be8f04daddee9d08d44ea891e" } }, "team_count": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-18
} }, "team_count": "", "team_count_link": { "team_count": "", "id": "1", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "team_name": [{ "id": "1", "name": "Global", "name_2": "", "primary": true }], "email": [], "email1": "", "email2": "", "invalid_email": "", "email_opt_out": "", "email_addresses_non_primary": "", "_acl": {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Check_for_Duplicate_Records/index.html
61c990020f1e-19
"email_addresses_non_primary": "", "_acl": { "fields": {} }, "_module": "Accounts", "duplicate_check_rank": 8 }] } Download You can download the full API example here. 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/PHP/How_to_Check_for_Duplicate_Records/index.html
dc2a1a653323-0
How to Favorite a Record Overview A PHP example demonstrating how to favorite a record using the v11 <module>/:record/favorite REST PUT API endpoint. Favoriting a Record Authenticating First, you will need to authenticate to the Sugar API. An example is shown below: <?php $instance_url = "http://{site_url}/rest/v11"; $username = "admin"; $password = "password"; //Login - POST /oauth2/token $auth_url = $instance_url . "/oauth2/token"; $oauth2_token_arguments = array( "grant_type" => "password", //client id - default is sugar. //It is recommended to create your own in Admin > OAuth Keys "client_id" => "sugar",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Favorite_a_Record/index.html
dc2a1a653323-1
"client_id" => "sugar", "client_secret" => "", "username" => $username, "password" => $password, //platform type - default is base. //It is recommend to change the platform to a custom name such as "custom_api" to avoid authentication conflicts. "platform" => "custom_api" ); $auth_request = curl_init($auth_url); curl_setopt($auth_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($auth_request, CURLOPT_HEADER, false); curl_setopt($auth_request, CURLOPT_SSL_VERIFYPEER, 0);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Favorite_a_Record/index.html
dc2a1a653323-2
curl_setopt($auth_request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($auth_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($auth_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json" )); //convert arguments to json $json_arguments = json_encode($oauth2_token_arguments); curl_setopt($auth_request, CURLOPT_POSTFIELDS, $json_arguments); //execute request $oauth2_token_response = curl_exec($auth_request); //decode oauth2 response to get token $oauth2_token_response_obj = json_decode($oauth2_token_response);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Favorite_a_Record/index.html
dc2a1a653323-3
$oauth_token = $oauth2_token_response_obj->access_token; More information on authenticating can be found in the How to Authenticate and Log Out example and /oauth2/logout endpoint documentation. Favoriting a Record Next, we can favorite a specific record using the /<module>/:record/favorite endpoint. //Favorite record - PUT //:record/favorite $favorite_url = $instance_url . "/Accounts/ae8b1783-404a-fcb8-1e1e-56f1cc52cd1a/favorite"; $favorite_request = curl_init($favorite_url); curl_setopt($favorite_request, CURLOPT_CUSTOMREQUEST, "PUT");
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Favorite_a_Record/index.html
dc2a1a653323-4
curl_setopt($favorite_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($favorite_request, CURLOPT_HEADER, false); curl_setopt($favorite_request, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($favorite_request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($favorite_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($favorite_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "oauth-token: {$oauth_token}" )); //execute request $favorite_response = curl_exec($favorite_request);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Favorite_a_Record/index.html
dc2a1a653323-5
)); //execute request $favorite_response = curl_exec($favorite_request); More information on theunfavorite API can be found in the /<module>/:record/favorite PUT documentation. Request Payload The data sent to the server is shown below: This endpoint does not accept any request arguments. Response The data received from the server is shown below: { "id": "ae8b1783-404a-fcb8-1e1e-56f1cc52cd1a", "name": "Union Bank", "date_entered": "2016-03-22T17:49:50-05:00", "date_modified": "2016-03-30T17:44:20-05:00", "modified_user_id": "1",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Favorite_a_Record/index.html
dc2a1a653323-6
"modified_user_id": "1", "modified_by_name": "Administrator", "modified_user_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": [], "delete": "no", "_hash": "8e11bf9be8f04daddee9d08d44ea891e" } }, "created_by": "1", "created_by_name": "Administrator", "created_by_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": [], "delete": "no",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Favorite_a_Record/index.html
dc2a1a653323-7
"fields": [], "delete": "no", "_hash": "8e11bf9be8f04daddee9d08d44ea891e" } }, "description": "", "deleted": false, "facebook": "", "twitter": "", "googleplus": "", "account_type": "Customer", "industry": "Banking", "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": "Ohio",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Favorite_a_Record/index.html
dc2a1a653323-8
"billing_address_city": "Ohio", "billing_address_state": "CA", "billing_address_postalcode": "25159", "billing_address_country": "USA", "rating": "", "phone_office": "(065) 489-6104", "phone_alternate": "", "website": "www.qahr.edu", "ownership": "", "employees": "", "ticker_symbol": "", "shipping_address_street": "67321 West Siam St.", "shipping_address_street_2": "", "shipping_address_street_3": "", "shipping_address_street_4": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Favorite_a_Record/index.html
dc2a1a653323-9
"shipping_address_street_4": "", "shipping_address_city": "Ohio", "shipping_address_state": "CA", "shipping_address_postalcode": "25159", "shipping_address_country": "USA", "parent_id": "", "sic_code": "", "duns_num": "", "parent_name": "", "member_of": { "name": "", "id": "", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "campaign_id": "", "campaign_name": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Favorite_a_Record/index.html
dc2a1a653323-10
"campaign_id": "", "campaign_name": "", "campaign_accounts": { "name": "", "id": "", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "following": true, "my_favorite": true, "tag": [], "assigned_user_id": "seed_sarah_id", "assigned_user_name": "Sarah Smith", "assigned_user_link": { "full_name": "Sarah Smith", "id": "seed_sarah_id", "_acl": { "fields": [],
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Favorite_a_Record/index.html
dc2a1a653323-11
"_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "team_count": "", "team_count_link": { "team_count": "", "id": "West", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "team_name": [{ "id": "East", "name": "East", "name_2": "", "primary": false }, { "id": 1, "name": "Global", "name_2": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Favorite_a_Record/index.html
dc2a1a653323-12
"name": "Global", "name_2": "", "primary": false }, { "id": "West", "name": "West", "name_2": "", "primary": true }], "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/PHP/How_to_Favorite_a_Record/index.html
dc2a1a653323-13
"reply_to_address": false }], "email1": "[email protected]", "email2": "[email protected]", "invalid_email": false, "email_opt_out": false, "email_addresses_non_primary": "", "_acl": { "fields": {} }, "_module": "Accounts" } Download You can download the full API example here. 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/PHP/How_to_Favorite_a_Record/index.html
9be5aeab2318-0
How to Filter a List of Records Overview A PHP example demonstrating how to filter records using the v11 /<module>/filter REST POST endpoints. Filtering Records Authenticating First, you will need to authenticate to the Sugar API. An example is shown below: <?php $instance_url = "http://{site_url}/rest/v11"; $username = "admin"; $password = "password"; //Login - POST /oauth2/token $auth_url = $instance_url . "/oauth2/token"; $oauth2_token_arguments = array( "grant_type" => "password", //client id - default is sugar. //It is recommended to create your own in Admin > OAuth Keys "client_id" => "sugar",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Filter_a_List_of_Records/index.html
9be5aeab2318-1
"client_id" => "sugar", "client_secret" => "", "username" => $username, "password" => $password, //platform type - default is base. //It is recommend to change the platform to a custom name such as "custom_api" to avoid authentication conflicts. "platform" => "custom_api" ); $auth_request = curl_init($auth_url); curl_setopt($auth_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($auth_request, CURLOPT_HEADER, false); curl_setopt($auth_request, CURLOPT_SSL_VERIFYPEER, 0);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Filter_a_List_of_Records/index.html
9be5aeab2318-2
curl_setopt($auth_request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($auth_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($auth_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json" )); //convert arguments to json $json_arguments = json_encode($oauth2_token_arguments); curl_setopt($auth_request, CURLOPT_POSTFIELDS, $json_arguments); //execute request $oauth2_token_response = curl_exec($auth_request); //decode oauth2 response to get token $oauth2_token_response_obj = json_decode($oauth2_token_response);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Filter_a_List_of_Records/index.html
9be5aeab2318-3
$oauth_token = $oauth2_token_response_obj->access_token; More information on authenticating can be found in the How to Authenticate and Log Out example and /oauth2/logout endpoint documentation. Filtering Records Next, we can filter the records we want to return using the /<module>/filter endpoint with a POST request. //Identify records to export - POST /<module>/filter $filter_url = $instance_url . "/Accounts/filter"; $filter_arguments = array( "filter" => array( array( '$or' => array( array( //name starts with 'a' "name" => array( '$starts'=>"A", ) ), array(
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Filter_a_List_of_Records/index.html
9be5aeab2318-4
) ), array( //name starts with 'b' "name" => array( '$starts'=>"b", ) ) ), ), ), "max_num" => 2, "offset" => 0, "fields" => "id", "order_by" => "date_entered", "favorites" => false, "my_items" => false, ); $filter_request = curl_init($filter_url); curl_setopt($filter_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($filter_request, CURLOPT_HEADER, false);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Filter_a_List_of_Records/index.html
9be5aeab2318-5
curl_setopt($filter_request, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($filter_request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($filter_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($filter_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "oauth-token: {$oauth_token}" )); //convert arguments to json $json_arguments = json_encode($filter_arguments); curl_setopt($filter_request, CURLOPT_POSTFIELDS, $json_arguments); //execute request $filter_response = curl_exec($filter_request); //decode json
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Filter_a_List_of_Records/index.html
9be5aeab2318-6
$filter_response = curl_exec($filter_request); //decode json $filter_response_obj = json_decode($filter_response); More information on the filter API can be found in the /<module>/filter documentation. Note : The /<module>/filter endpoint can be called using a GET request as well, though long URL requests can have issues so the POST request is recommended.  Request Payload The data sent to the server is shown below: { "filter":[ { "$or":[ { "name":{ "$starts":"A" } }, { "name":{ "$starts":"b" } } ] } ], "max_num":2,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Filter_a_List_of_Records/index.html
9be5aeab2318-7
] } ], "max_num":2, "offset":0, "fields":"id", "order_by":"date_entered", "favorites":false, "my_items":false } Response The data received from the server is shown below: { "next_offset":2, "records":[ { "id":"f16760a4-3a52-f77d-1522-5703ca28925f", "date_modified":"2016-04-05T10:23:28-04:00", "_acl":{ "fields":{ } }, "_module":"Accounts" }, {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Filter_a_List_of_Records/index.html
9be5aeab2318-8
}, "_module":"Accounts" }, { "id":"ec409fbb-2b22-4f32-7fa1-5703caf78dc3", "date_modified":"2016-04-05T10:23:28-04:00", "_acl":{ "fields":{ } }, "_module":"Accounts" } ] } Download You can download the full API example using POST here and using GET here. 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/PHP/How_to_Filter_a_List_of_Records/index.html
d08122c5a06e-0
How to Unfavorite a Record Overview A PHP example demonstrating how to unfavorite a record using the v11 /<module>/:record/unfavorite REST PUT endpoint. Unfavoriting a Record Authenticating First, you will need to authenticate to the Sugar API. An example is shown below: <?php $instance_url = "http://{site_url}/rest/v11"; $username = "admin"; $password = "password"; //Login - POST /oauth2/token $auth_url = $instance_url . "/oauth2/token"; $oauth2_token_arguments = array( "grant_type" => "password", //client id - default is sugar. //It is recommended to create your own in Admin > OAuth Keys
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Unfavorite_a_Record/index.html
d08122c5a06e-1
//It is recommended to create your own in Admin > OAuth Keys "client_id" => "sugar", "client_secret" => "", "username" => $username, "password" => $password, //platform type - default is base. //It is recommend to change the platform to a custom name such as "custom_api" to avoid authentication conflicts. "platform" => "custom_api" ); $auth_request = curl_init($auth_url); curl_setopt($auth_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($auth_request, CURLOPT_HEADER, false); curl_setopt($auth_request, CURLOPT_SSL_VERIFYPEER, 0);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Unfavorite_a_Record/index.html
d08122c5a06e-2
curl_setopt($auth_request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($auth_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($auth_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json" )); //convert arguments to json $json_arguments = json_encode($oauth2_token_arguments); curl_setopt($auth_request, CURLOPT_POSTFIELDS, $json_arguments); //execute request $oauth2_token_response = curl_exec($auth_request); //decode oauth2 response to get token $oauth2_token_response_obj = json_decode($oauth2_token_response);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Unfavorite_a_Record/index.html
d08122c5a06e-3
$oauth_token = $oauth2_token_response_obj->access_token; More information on authenticating can be found in the How to Authenticate and Log Out example and /oauth2/logout endpoint documentation. Unfavoriting a Record Next, we can unfavorite a specific record using the /<module>/:record/unfavorite endpoint. //Unfavorite record - PUT //:record/unfavorite $unfavorite_url = $instance_url . "/Accounts/ae8b1783-404a-fcb8-1e1e-56f1cc52cd1a/unfavorite"; $unfavorite_request = curl_init($unfavorite_url); curl_setopt($unfavorite_request, CURLOPT_CUSTOMREQUEST, "PUT");
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Unfavorite_a_Record/index.html
d08122c5a06e-4
curl_setopt($unfavorite_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($unfavorite_request, CURLOPT_HEADER, false); curl_setopt($unfavorite_request, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($unfavorite_request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($unfavorite_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($unfavorite_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "oauth-token: {$oauth_token}" )); //execute request
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Unfavorite_a_Record/index.html
d08122c5a06e-5
)); //execute request $unfavorite_response = curl_exec($unfavorite_request); More information on the unfavorite API can be found in the /<module>/:record/unfavorite PUT documentation. Request Payload The data sent to the server is shown below: This endpoint does not accept any request arguments. Response The data received from the server is shown below: { "id": "ae8b1783-404a-fcb8-1e1e-56f1cc52cd1a", "name": "Union Bank", "date_entered": "2016-03-22T17:49:50-05:00", "date_modified": "2016-03-30T17:44:20-05:00", "modified_user_id": "1",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Unfavorite_a_Record/index.html
d08122c5a06e-6
"modified_user_id": "1", "modified_by_name": "Administrator", "modified_user_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": [], "delete": "no", "_hash": "8e11bf9be8f04daddee9d08d44ea891e" } }, "created_by": "1", "created_by_name": "Administrator", "created_by_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": [], "delete": "no",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Unfavorite_a_Record/index.html
d08122c5a06e-7
"fields": [], "delete": "no", "_hash": "8e11bf9be8f04daddee9d08d44ea891e" } }, "description": "", "deleted": false, "facebook": "", "twitter": "", "googleplus": "", "account_type": "Customer", "industry": "Banking", "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": "Ohio",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Unfavorite_a_Record/index.html
d08122c5a06e-8
"billing_address_city": "Ohio", "billing_address_state": "CA", "billing_address_postalcode": "25159", "billing_address_country": "USA", "rating": "", "phone_office": "(065) 489-6104", "phone_alternate": "", "website": "www.qahr.edu", "ownership": "", "employees": "", "ticker_symbol": "", "shipping_address_street": "67321 West Siam St.", "shipping_address_street_2": "", "shipping_address_street_3": "", "shipping_address_street_4": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Unfavorite_a_Record/index.html
d08122c5a06e-9
"shipping_address_street_4": "", "shipping_address_city": "Ohio", "shipping_address_state": "CA", "shipping_address_postalcode": "25159", "shipping_address_country": "USA", "parent_id": "", "sic_code": "", "duns_num": "", "parent_name": "", "member_of": { "name": "", "id": "", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "campaign_id": "", "campaign_name": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Unfavorite_a_Record/index.html
d08122c5a06e-10
"campaign_id": "", "campaign_name": "", "campaign_accounts": { "name": "", "id": "", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "following": true, "my_favorite": false, "tag": [], "assigned_user_id": "seed_sarah_id", "assigned_user_name": "Sarah Smith", "assigned_user_link": { "full_name": "Sarah Smith", "id": "seed_sarah_id", "_acl": { "fields": [],
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Unfavorite_a_Record/index.html
d08122c5a06e-11
"_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "team_count": "", "team_count_link": { "team_count": "", "id": "West", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "team_name": [{ "id": "East", "name": "East", "name_2": "", "primary": false }, { "id": 1, "name": "Global", "name_2": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Unfavorite_a_Record/index.html
d08122c5a06e-12
"name": "Global", "name_2": "", "primary": false }, { "id": "West", "name": "West", "name_2": "", "primary": true }], "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/PHP/How_to_Unfavorite_a_Record/index.html
d08122c5a06e-13
"reply_to_address": false }], "email1": "[email protected]", "email2": "[email protected]", "invalid_email": false, "email_opt_out": false, "email_addresses_non_primary": "", "_acl": { "fields": {} }, "_module": "Accounts" } Download You can download the full API example here. 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/PHP/How_to_Unfavorite_a_Record/index.html
ec98127e489e-0
How to Follow a Record Overview A PHP example demonstrating how to follow a record using the v11 /<module>/:record/subscribe REST POST endpoint. Following a Record Authenticating First, you will need to authenticate to the Sugar API. An example is shown below: <?php $instance_url = "http://{site_url}/rest/v11"; $username = "admin"; $password = "password"; //Login - POST /oauth2/token $auth_url = $instance_url . "/oauth2/token"; $oauth2_token_arguments = array( "grant_type" => "password", //client id - default is sugar. //It is recommended to create your own in Admin > OAuth Keys "client_id" => "sugar",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Follow_a_Record/index.html
ec98127e489e-1
"client_id" => "sugar", "client_secret" => "", "username" => $username, "password" => $password, //platform type - default is base. //It is recommend to change the platform to a custom name such as "custom_api" to avoid authentication conflicts. "platform" => "custom_api" ); $auth_request = curl_init($auth_url); curl_setopt($auth_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($auth_request, CURLOPT_HEADER, false); curl_setopt($auth_request, CURLOPT_SSL_VERIFYPEER, 0);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Follow_a_Record/index.html