id
stringlengths 14
16
| text
stringlengths 33
5.27k
| source
stringlengths 105
270
|
---|---|---|
91997035f4c2-0 | /<module>/config GET
Overview
Retrieves the config settings for a given module.
Summary
This endpoint is normally used for the forecasting module.
Request Arguments
This endpoint does not accept any request arguments.
Response Arguments
Name
Type
Description
<config field>
<config field type>
The list of config fields will be returned.
Response
{
"is_setup":1,
"is_upgrade":0,
"has_commits":1,
"timeperiod_type":"chronological",
"timeperiod_interval":"Annual",
"timeperiod_leaf_interval":"Quarter",
"timeperiod_start_date":"2013-01-01",
"timeperiod_shown_forward":2, | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/moduleconfig_GET/index.html |
91997035f4c2-1 | "timeperiod_shown_forward":2,
"timeperiod_shown_backward":2,
"forecast_ranges":"show_binary",
"buckets_dom":"commit_stage_binary_dom",
"show_binary_ranges":{
"include":{
"min":70,
"max":100
},
"exclude":{
"min":0,
"max":69
}
},
"show_buckets_ranges":{
"include":{
"min":85,
"max":100
},
"upside":{
"min":70,
"max":84
},
"exclude":{
"min":0,
"max":69
}
}, | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/moduleconfig_GET/index.html |
91997035f4c2-2 | "min":0,
"max":69
}
},
"show_custom_buckets_ranges":{
"include":{
"min":85,
"max":100
},
"upside":{
"min":70,
"max":84
},
"exclude":{
"min":0,
"max":69
}
},
"sales_stage_won":[
"Closed Won"
],
"sales_stage_lost":[
"Closed Lost"
],
"show_worksheet_likely":1,
"show_worksheet_best":1,
"show_worksheet_worst":0,
"show_projected_likely":1, | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/moduleconfig_GET/index.html |
91997035f4c2-3 | "show_projected_likely":1,
"show_projected_best":1,
"show_projected_worst":0,
"show_forecasts_commit_warnings":1
}
Change Log
Version
Change
v10
Added /<module>/config GET endpoint.
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/moduleconfig_GET/index.html |
bc95748cf164-0 | /OutboundEmail POST
Overview
Create a new OutboundEmail configuration to use to send emails over SMTP.
Summary
Each configuration that is created is validated first by attempting to connect to the server.
Request Arguments
Name
Type
Description
Required
name
String
The display name of the configuration.
True
mail_sendtype
String
Only SMTP is supported. This field is defaulted to smtp.
False
mail_smtptype
String
The email provider through which emails are sent. This is merely a convenience which allows for
prepopulating data in the UI. Possible values are: google, exchange, outlook, other. other is the
default.
False
mail_smtpserver | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/OutboundEmail_POST/index.html |
bc95748cf164-1 | False
mail_smtpserver
String
The address of the SMTP server.
True
mail_smtpport
Integer
The port on which to connect to the SMTP server. The default is 465, which assumes you are using
SSL.
False
mail_smtpuser
String
The username for authenticating with the SMTP server. It is only required if mail_smtpauth_req is
true.
False
mail_smtppass
String
The password for authenticating with the SMTP server. It is only required if mail_smtpauth_req is
true.
False | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/OutboundEmail_POST/index.html |
bc95748cf164-2 | true.
False
mail_smtpauth_req
Boolean
Indicates whether or not the SMTP server requires authentication. The default is false.
False
mail_smtpssl
String
The encryption protocol used for connecting to the SMTP server. "0" represents no encryption.
"1" represents SSL. "2" represents TLS. The default is SSL.
False
Request
{
"name": "My Exchange Account",
"mail_smtptype": "exchange",
"mail_smtpserver": "smtp.example.com",
"mail_smtpport": 465,
"mail_smtpuser": "[email protected]", | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/OutboundEmail_POST/index.html |
bc95748cf164-3 | "mail_smtpuser": "[email protected]",
"mail_smtppass": "P@55w0rd",
"mail_smtpauth_req": true,
"mail_smtpssl": "1"
}
Response Arguments
Name
Type
Description
name
String
The display name of the configuration.
type
String
Only user configuration may be created using this endpoint, so user will always be
returned. system and system-override configurations are always created by the application.
user_id
String
The current user's ID. The current user may only create configurations for himself or herself.
mail_sendtype
String | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/OutboundEmail_POST/index.html |
bc95748cf164-4 | mail_sendtype
String
Only SMTP is supported, so smtp will always be returned.
mail_smtptype
String
The email provider through which emails are sent. Possible values are: google, exchange, outlook, other.
mail_smtpserver
String
The address of the SMTP server.
mail_smtpport
Integer
The port on which to connect to the SMTP server.
mail_smtpuser
String
The username for authenticating with the SMTP server.
mail_smtppass
Boolean
Indicates whether or not a password exists. true is returned for this field when a password does | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/OutboundEmail_POST/index.html |
bc95748cf164-5 | exist. This field is not included in the response when a password does not exist.
mail_smtpauth_req
Boolean
Indicates whether or not the SMTP server requires authentication.
mail_smtpssl
String
The encryption protocol used for connecting to the SMTP server.
Response
{
"id": "e04ce998-960e-11e6-8628-3c15c2d582c6",
"name": "My Exchange Account",
"type": "user",
"user_id": "e91b1fa7-1bd8-3c71-be96-512e643f9ca4",
"mail_sendtype": "smtp",
"mail_smtptype": "exchange", | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/OutboundEmail_POST/index.html |
bc95748cf164-6 | "mail_smtptype": "exchange",
"mail_smtpserver": "smtp.example.com",
"mail_smtpport": 465,
"mail_smtpuser": "[email protected]",
"mail_smtppass": true,
"mail_smtpauth_req": true,
"mail_smtpssl": "1",
"deleted": false,
"my_favorite": false,
"_acl": {
"fields": {}
},
"_module": "OutboundEmail"
}
Change Log
Version
Change
v10
Added /OutboundEmail POST endpoint.
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/OutboundEmail_POST/index.html |
516d66be18da-0 | /Emails/:record/link POST
Overview
Creates a relationship to a pre-existing email.
Summary
Cannot link existing Notes records as attachments (link: attachments) and existing EmailParticipants records
as a sender (link: from) or recipients(links: to, cc, bcc). All other operations
described in Relate Record API are supported.
Change Log
Version
Change
v10
Added /Emails/:record/link POST endpoint.
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/Emailsrecordlink_POST/index.html |
ce0c3eca5e6d-0 | /Administration/packages/:id/enable GET
Overview
[ADMIN] PackageManager enable a package.
Summary
Enable the specified package. Package id hash must be provided. Package id could be found in installed package list.
Response
Returns http status 200 OK and enabled package ID if request is successful.
{
"id": "56365210-4cce-11ea-a7bf-acde48001122"
}
Otherwise returns http status 4xx with errors.
{
"error": "not_found",
"error_message": "Could not find package by ID."
}
Change Log
Version
Change
v11.8
Added /Administration/packages/:id/enable GET endpoint.
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/Administrationpackagesidenable_GET/index.html |
eddc6111034c-0 | /<module>/:record/path GET
Overview
Retrieves all parents of selected record.
Request Arguments
Name
Type
Description
Required
module
String
The name of sugar module that contains a nested set data and implements the NestedSetInterface.
True
:record
String
The ID of record
True
Response Arguments
This endpoint does not return any response arguments.
Response
[{
"id": "045c03b9-327b-11e4-818b-5404a67f3363",
"name": "Audit",
"date_entered": null,
"date_modified": null,
"modified_user_id": null,
"created_by": null, | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/modulerecordpath_GET/index.html |
eddc6111034c-1 | "modified_user_id": null,
"created_by": null,
"description": null,
"deleted": "0",
"source_id": null,
"source_type": null,
"source_meta": null,
"root": "935d3e07-327a-11e4-818b-5404a67f3363",
"lft": "10",
"rgt": "19",
"level": "1"
}, {
"id": "045c1de6-327b-11e4-818b-5404a67f3363",
"name": "Financial",
"date_entered": null,
"date_modified": null,
"modified_user_id": null, | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/modulerecordpath_GET/index.html |
eddc6111034c-2 | "date_modified": null,
"modified_user_id": null,
"created_by": null,
"description": null,
"deleted": "0",
"source_id": null,
"source_type": null,
"source_meta": null,
"root": "935d3e07-327a-11e4-818b-5404a67f3363",
"lft": "11",
"rgt": "14",
"level": "2"
}]
Change Log
Version
Change
v10
Added /<module>/:record/path GET endpoint.
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/modulerecordpath_GET/index.html |
18776d5cc6fa-0 | /Forecasts/enum/selectedTimePeriod GET
ForecastsApi Timeperiod filter info
Summary:
This returns the timeperiods with respect to the forward/backward options selected. For example, if we elect to use
quarterly timeperiods and 2 forward and 2 backward timeperiod intervals are set, then 5 years worth of timeperiods
will be returned (2 backward + current + 2 forward).
Query Parameters:
Param
Description
Optional
This endpoint does not accept any parameters.
Input Example:
Output Example:
{ "d181230a-a7e0-3176-d10f-50f8530a51ce" : "Q1 (01/01/2012 - 03/31/2012)", | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/ForecastsenumselectedTimePeriod_GET/index.html |
18776d5cc6fa-1 | "d2bc58ef-21c4-27d5-e416-50f853db29f9" : "Q2 (04/01/2012 - 06/30/2012)",
"d3db853e-94d6-b5ac-98af-50f8530689be" : "Q3 (07/01/2012 - 09/30/2012)",
"d519f521-5303-1cfc-24f5-50f8537f5b54" : "Q4 (10/01/2012 - 12/31/2012)",
"dcc2885a-5889-ea75-84c8-50f853d1a5ba" : "Q1 (01/01/2013 - 03/31/2013)", | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/ForecastsenumselectedTimePeriod_GET/index.html |
18776d5cc6fa-2 | "ddc24224-c6c9-04aa-7869-50f853db2ea2" : "Q2 (04/01/2013 - 06/30/2013)",
"deadcfd3-41ed-5f6b-ce5b-50f853de6ef6" : "Q3 (07/01/2013 - 09/30/2013)",
"dfaa3724-6295-8ddb-6d14-50f853047fcc" : "Q4 (10/01/2013 - 12/31/2013)",
"e1ceee19-c8dd-afdd-e797-50f8538d900a" : "Q1 (01/01/2014 - 03/31/2014)", | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/ForecastsenumselectedTimePeriod_GET/index.html |
18776d5cc6fa-3 | "e307594a-c12a-6be6-74b7-50f85351c574" : "Q2 (04/01/2014 - 06/30/2014)",
"e469239c-3f71-a48e-cda1-50f853214b6a" : "Q3 (07/01/2014 - 09/30/2014)",
"e57f4889-cefd-4356-6d82-50f85350decd" : "Q4 (10/01/2014 - 12/31/2014)"
}
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/ForecastsenumselectedTimePeriod_GET/index.html |
dee1dbedbbed-0 | /theme POST
Overview
Updates the variables.less (less file containing customizable vars in the theme folder) with the set of variables passed as arguments.
Request Arguments
Name
Type
Description
Required
platform
String
The theme platform - /themes/clients/***PLATFORM***/themeName/. Accepted values are 'base' and 'portal'.
True
themeName
String
The theme name - /themes/clients/platform/***THEMENAME***/.
True
<theme variable>
String
The variables of the theme
False
Request
{
platform:'portal',
themeName:'default',
primary:'default',
secondary:'#aaaaaa',
primaryBtn:'#bbbbbb',
}
Response Arguments
Name
Type
Description
<css path>
String | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/theme_POST/index.html |
dee1dbedbbed-1 | Name
Type
Description
<css path>
String
Returns the path of the new bootstrap.css file.
Response
"http:\/\/sugarcrm\/cache\/themes\/clients\/base\/default\/6a031485bf5239b9462e4aaba72a4646.css"
Change Log
Version
Change
v10
Added /<theme> POST endpoint.
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Endpoints/theme_POST/index.html |
337d95fdb7c8-0 | Extending Endpoints
Overview
How to add your own custom endpoints to the REST API.
Custom Endpoints
With the REST architecture, you can easily define your own endpoint. All custom global endpoints will be located in ./custom/clients/<client>/api/. All custom endpoints specific to a module will be located in ./custom/modules/<module>/clients/<client>/api/.
Note: The Sugar application client type is "base". More information on the various client types can be found in the Clients section.
Defining New Endpoints | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-1 | Defining New Endpoints
The endpoint class will be created in ./custom/clients/<client>/api/ and will extend SugarApi. Within this class, you will need to implement a registerApiRest() function that will define your endpoint paths. When creating a new endpoint, please note that the file name must match the class name for the endpoint definitions. The example below demonstrates creating a GET endpoint.
./custom/clients/base/api/MyEndpointsApi.php
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class MyEndpointsApi extends SugarApi
{
public function registerApiRest()
{
return array(
//GET
'MyGetEndpoint' => array(
//request type
'reqType' => 'GET',
//set authentication | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-2 | //request type
'reqType' => 'GET',
//set authentication
'noLoginRequired' => false,
//endpoint path
'path' => array('MyEndpoint', 'GetExample', '?'),
//endpoint variables
'pathVars' => array('', '', 'data'),
//method to call
'method' => 'MyGetMethod',
//short help string to be displayed in the help documentation
'shortHelp' => 'An example of a GET endpoint',
//long help to be displayed in the help documentation
'longHelp' => 'custom/clients/base/api/help/MyEndPoint_MyGetEndPoint_help.html',
),
);
}
/**
* Method to be used for my MyEndpoint/GetExample endpoint
*/ | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-3 | * Method to be used for my MyEndpoint/GetExample endpoint
*/
public function MyGetMethod($api, $args)
{
//custom logic
return $args;
}
}
?>
Note: The file name must match the class name for the endpoint definitions. Given the example above, a class name of MyEndpointsApi must be created as MyEndpointsApi.php.
registerApiRest() Method
Your extended class will contain two methods. The first method is registerApiRest() which will return an array that defines your REST endpoints. Each endpoint will need the following properties:
Name
Type
Description
reqType
Array | String
An array of one or many request types of the endpoint. Possible values are: GET, PUT, POST and DELETE.
noLoginRequired
Boolean | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-4 | noLoginRequired
Boolean
Determines whether the endpoint is authenticated. Setting this value to true will remove the authentication requirement.
path
Array
The endpoint path. An endpoint path of:
'path' => array('MyEndpoint', 'GetExample'),
Will equate to the URL path of http://{site url}/rest/{REST VERSION}/MyEndpoint/GetExample.
To pass in a variable string to your endpoint, you will add a path of '?'. This will allow you to pass URL data to your selected method given that it is specified in the pathVars.
pathVars
Array
The path variables. For each path on your endpoint, you can opt to pass its value in as a parameter to your selected method. An empty path variable will ignore the path.
Example:
'path' => array('MyEndpoint', 'GetExample', '?'), | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-5 | 'path' => array('MyEndpoint', 'GetExample', '?'),
'pathVars' => array('', '', 'data'),
The above will pass information to your selected method as the $args parameter when calling http://{site url}/rest/{REST VERSION}/MyEndpoint/GetExample/MyData
method
String
The method to pass the pathVars to. This can be named anything you choose and will be located in your SugarApi extended class.
shortHelp
String
A short help string for developers when looking at the help documentation.
longHelp
String
Path to a long help file. This file will be loaded when a user clicks an endpoint from the help documentation.
minVersion
Integer
The minimum API Version this endpoint can be used with. See Scoring Section below.Â
maxVersion
Integer | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-6 | maxVersion
IntegerÂ
The maximum API Version this endpoint can be used with. See Scoring Section below.Â
extraScore
IntegerÂ
Add an extra score value to the Scoring of this endpoint, to place priority on its usage. See Scoring Section below.
Endpoint Method
The second method can be named anything you choose but it is important to note that it will need to match the name of the method you specified for your endpoint. This method will require the parameters $api and $args. The MyGetMethod() in the example above will be used when the endpoint MyEndpoint/GetExample is called. Any path variables, query string parameters or posted data will be available in the $args parameter for you to work with.
public function MyEndpointMethod($api, $args)
{
//logic
return $returnData;
}
Help Documentation | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-7 | {
//logic
return $returnData;
}
Help Documentation
The final step once you have your endpoint working is to document it. This file can reside anywhere in the system and will be referenced in your endpoints longHelp property. An example of the help documentation can be found below:
custom/clients/base/api/help/MyEndPoint_MyGetEndPoint_help.html
<h2>Overview</h2>
<span class="lead">
A custom GET endpoint. Returns the $args parameter that is passed to the endpoint method.
</span>
<h2>Path Variables</h2>
<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody> | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-8 | </tr>
</thead>
<tbody>
<tr>
<td>
:data
</td>
<td>
Data string to pass to the endpoint.
</td>
</tr>
</tbody>
</table>
<h2>Input Parameters</h2>
<span class="lead">
This endpoint does not accept any input parameters.
</span>
<h2>Result</h2>
<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
__sugar_url | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-9 | <tr>
<td>
__sugar_url
</td>
<td>
String
</td>
<td>
The endpoint path.
</td>
</tr>
<tr>
<td>
data
</td>
<td>
String
</td>
<td>
The data from path variable.
</td>
</tr>
</tbody>
</table>
<h3>Output Example</h3>
<pre class="pre-scrollable">
{
"__sugar_url":"v10\/MyEndpoint\/GetExample\/MyData",
"data":"MyData"
}
</pre>
<h2>Change Log</h2>
<table class="table table-hover"> | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-10 | <table class="table table-hover">
<thead>
<tr>
<th>Version</th>
<th>Change</th>
</tr>
</thead>
<tbody>
<tr>
<td>
v10
</td>
<td>
Added <code>/MyEndpoint/GetExample/:data</code> GET endpoint.
</td>
</tr>
</tbody>
</table>
Quick Repair and Rebuild
Once all of the files are in place, you will need to navigate to Admin > Repair > Quick Repair and Rebuild. This will rebuild the ./cache/file_map.php and ./cache/include/api/ServiceDictionary.rest.php files to make your endpoint available.
Example | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-11 | Example
./custom/clients/base/api/MyEndpointsApi.php
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class MyEndpointsApi extends SugarApi
{
public function registerApiRest()
{
return array(
//GET & POST
'MyGetEndpoint' => array(
//request type
'reqType' => array('GET','POST'),
//set authentication
'noLoginRequired' => false,
//endpoint path
'path' => array('MyEndpoint', 'GetExample', '?'),
//endpoint variables
'pathVars' => array('', '', 'data'),
//method to call
'method' => 'MyGetMethod', | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-12 | //method to call
'method' => 'MyGetMethod',
//short help string to be displayed in the help documentation
'shortHelp' => 'An example of a GET endpoint',
//long help to be displayed in the help documentation
'longHelp' => 'custom/clients/base/api/help/MyEndPoint_MyGetEndPoint_help.html',
),
);
}
/**
* Method to be used for my MyEndpoint/GetExample endpoint
*/
public function MyGetMethod($api, $args)
{
//custom logic
return $args;
}
}
?>
Redefining Existing Endpoints | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-13 | }
}
?>
Redefining Existing Endpoints
With endpoints, you may have a need to extend an existing endpoint to meet your needs. When doing this it is important that you do not remove anything from the return array of the endpoint. Doing so could result in unexpected behavior due to other functionality using the same endpoint.
For this example, we will extend the ping endpoint to return "Pong <timestamp>". To do this, we will need to extend the existing PingApi class and define our method overrides. When creating a new endpoint, please note that the file name must match the class name for the endpoint definitions. For our example, we will prefix the original class name with "custom" to create our overriding endpoint.
./custom/clients/base/api/CustomPingApi.php
<?php | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-14 | ./custom/clients/base/api/CustomPingApi.php
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once("clients/base/api/PingApi.php");
class CustomPingApi extends PingApi
{
public function registerApiRest()
{
//in case we want to add additional endpoints
return parent::registerApiRest();
}
//override to modify the ping function of the ping endpoint
public function ping($api, $args)
{
$result = parent::ping($api, $args);
//append the current timestamp
return $result . ' ' . time();
}
} | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-15 | return $result . ' ' . time();
}
}
Note: The file name must match the class name for the endpoint definitions. Given the example above, a class name of CustomPingApi must be created as CustomPingApi.php.
As you can see, we extended registerApiRest to fetch existing endpoint definitions in case we want to add our own. We then added an override for the ping method to return our new value. Once the file is in place you will need to navigate to Admin > Repair > Quick Repair and Rebuild. Once completed, any call made to <url>/rest/{REST VERSION}/ping will result in a response of "ping <timestamp>".
Endpoint Scoring | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-16 | Endpoint Scoring
When generating custom endpoints or overriding existing endpoints, the system can determine which endpoint to use based on the score placed on the registered endpoints. The scoring calculation works in the following manner for registered endpoints.
Route Path
Score
?
0.75
<module>
1.0
Exact Match
1.75
Custom
0.5
Endpoint 'extraScore' property
Defined Extra Score
Â
The defined Path and extraScore properties in the registerApiRest() method, help determine the score for any given Endpoint. The higher the score allows the API to determine which Endpoint is being used for a given request. For example, if you had extended the /Accounts/:record GET API Endpoint as follows:Â
/custom/modules/Accounts/clients/base/api/CustomAccountsApi.php
<?php | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-17 | <?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once("clients/base/api/ModuleApi.php");
class CustomAccountsApi extends ModuleApi
{
public function registerApiRest()
{
return array(
//GET & POST
'getAccount' => array(
//request type
'reqType' => array('GET'),
//set authentication
'noLoginRequired' => false,
//endpoint path
'path' => array('Accounts', '?'),
//endpoint variables
'pathVars' => array('module', 'record'),
//method to call
'method' => 'retrieveRecord',
//short help string to be displayed in the help documentation | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-18 | //short help string to be displayed in the help documentation
'shortHelp' => 'An example of a GET endpoint',
//long help to be displayed in the help documentation
'longHelp' => 'custom/clients/base/api/help/MyEndPoint_MyGetEndPoint_help.html',
),
);
}
/**
* Method to be used for my Accounts/:record endpoint
*/
public function retrieveRecord($api, $args)
{
//custom logic
return parent::retrieveRecord($api,$args);
}
}
?> | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-19 | }
}
?>
 This Endpoint will be used when accessing /Accounts/<record_id> since the Exact Match of Accounts in the path property gives a greater score than the <module> match that comes with the standard /<module>/:record Endpoint defined in ModuleApi.
Endpoint Versioning | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-20 | Endpoint Versioning
Part of the scoring calculation allows for versioning of the API Endpoints to accommodate the same endpoint path in the Rest API, for other versions of the API. If you have a custom Endpoint at /rest/v10/CustomEndpoint, and would like to alter the logic slightly for another use without deprecating or removing the old Endpoint, you can use the versioning techniques to have the new logic reside at /rest/v11/CustomEndpoint. The following table describes how the Versioning properties on the Endpoint definition affect the score of the Endpoint to allow the API to determine which Endpoint should be used for a given request.
 Property
ScoreÂ
 minVersion
0.02 + minVersion/1000Â
 maxVersion
0.02Â | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-21 | Â maxVersion
0.02Â
 minVersion === maxVersion (i.e. Both minVersion and maxVersion properties are defined on Endpoint to the same value)
0.06 + minVersion/1000
Â
To allow for additional Versions in the API, you will first need to customize the 'maxVersion' property in the $apiSettings array. To do this, create ./custom/include/api/metadata.php. Inside the file you can set the $apiSettings['maxVersion'] property as follows:
<?php
$apiSettings['maxVersion'] = 11;
Â
Once you have configured the Max Version property, you can then set the minVersion and maxVersion properties on the Endpoint definition in the custom registerApiRest() method. For example, the following Endpoint definitions:Â
<?php
...
return array( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-22 | <?php
...
return array(
'foo1' => array(
'reqType' => 'GET',
'path' => array('Accounts','config',
'pathVars' => array('module', 'record'),
'method' => 'foo1',
),
'foo2' => array(
'reqType' => 'GET',
'minVersion' => 11,
'path' => array('Accounts','config',
'pathVars' => array('module', 'record'),
'method' => 'foo2',
),
'foo3' => array(
'reqType' => 'GET',
'minVersion' => 11,
'maxVersion' => 11,
'path' => array('Accounts','config', | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-23 | 'path' => array('Accounts','config',
'pathVars' => array('module', 'record'),
'method' => 'foo3',
),
'foo4' => array(
'reqType' => 'GET',
'minVersion' => 11,
'maxVersion' => 12,
'path' => array('Accounts','config',
'pathVars' => array('module', 'record'),
'method' => 'foo3',
),
'foo5' => array(
'reqType' => 'GET',
'minVersion' => 14,
'path' => array('Accounts','config',
'pathVars' => array('module', 'record'),
'method' => 'foo5',
),
);
... | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
337d95fdb7c8-24 | 'method' => 'foo5',
),
);
...
With the above definitions, the following table provides the Expected Request for each Endpoint.
 Request URI
Best RouteÂ
 /rest/v10/Accounts/config
foo1
 /rest/v11/Accounts/config
foo3
 /rest/v12/Accounts/config
foo4Â
 /rest/v13/Accounts/config
foo2Â
 /rest/v14/Accounts/config
foo5Â
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Web_Services/REST_API/Extending_Endpoints/index.html |
744fc6bc4880-0 | Migration
Migrating Sugar instances and external data.
TopicsMigrating From On-Site to SugarCloudThe following article describes the process of migrating an on-site deployment to the SugarCloud environment.Migrating From SugarCloud to On-SiteOccasionally, system administrators will have the need to deploy versions of their instance hosted on Sugar's cloud service to an on-site system. Reasons for this type of deployment are:Migrating From a Broken Instance to a Clean InstallThe following article describes the process of migrating a potentially broken instance to a clean install.Importing RecordsCovers the Sugar structure when migrating data into the application.
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/index.html |
d818b55b98cb-0 | Migrating From SugarCloud to On-Site
Overview
Occasionally, system administrators will have the need to deploy versions of their instance hosted on Sugar's cloud service to an on-site system. Reasons for this type of deployment are:
Testing locally-developed modules
Migrating from SugarCloud to on-site
Prerequisites
Before migrating Sugar to an on-site environment, you will need to request a backup of your SugarCloud system by filing a case with the Sugar Support team. Once the backup request is received, SugarCRM will provide an FTP account where the following files can be downloaded:instance_name-YYYYMMDDHHmm.sql.gz (backup of database)
instance_name-YYYYMMDDHHmm-triggers.sql.gz (backup of database triggers) | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_Sugar_Cloud_to_On-Site/index.html |
d818b55b98cb-1 | instance_name-YYYYMMDDHHmm.files.tgz (backup of file system)
The local system must be running MySQL. Converting the database to another system, such as SQL Server or Oracle, requires special handling. For more information regarding this type of conversion, please contact your Account Manager.
On-site system administrators must be familiar with their stack and the tools (gunzip, tar, mysqladmin, mysql, etc.) referenced in this guide.
Note: It is the system administrator's responsibility to diagnose and troubleshoot issues specific to the stack (permissions, environment variables, etc.).
Steps to Complete
Deploy the backup files to a local system using the following steps:
Extract and import the SQL data as follows: | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_Sugar_Cloud_to_On-Site/index.html |
d818b55b98cb-2 | Extract and import the SQL data as follows:
Extract the SQL file via an archive utility (e.g. 7-Zip) or via command line such as: gunzip instance_name-YYYYMMDDHHmm.sql.gz
Create a database on your MySQL server via command line: mysqladmin -u mysql_username -p create instance_name
Or, if already logged into MySQL, with a command such as: CREATE DATABASE instance_name;
Import the SQL data to your MySQL server via the command line: mysql -u mysql_username database_name -p < instance_name-YYYYMMDDHHmm.sql
Extract the Triggers file via an archive utility (e.g. 7-Zip) or via command line such as: gunzip instance_name-YYYYMMDDHHmm.triggers.sql.gz | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_Sugar_Cloud_to_On-Site/index.html |
d818b55b98cb-3 | Import the Triggers data to your MySQL server via the command line: mysql -u mysql_username database_name -p < instance_name-YYYYMMDDHHmm.triggers.sql
Extract the tar file to your web server's web root directory (e.g. /var/www/html) with the following command: tar -C /var/www/html -xzf instance_name-YYYYMMDDHHmm.files.tgz
This will create a directory named "instance_name-YYYYMMDDHHmm" in your web root directory.
Rename the newly created directory: mv /var/www/html/instance_name-YYYYMMDDHHmm /var/www/html/instance_name
For Linux-based servers, perform the following actions: | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_Sugar_Cloud_to_On-Site/index.html |
d818b55b98cb-4 | For Linux-based servers, perform the following actions:
Change the ownership of the directory to be accessible by the Apache user and group. Please note that the user and group (e.g. apache, www-data, etc.) values can vary depending on your web server configuration. chown -R apache:apache /var/www/html/instance_name
Change the permissions of the directory to ensure files can be accessed by the application. The actual permission values may differ depending on server security settings. chmod -R 770 /var/www/html/instance_name
Edit the ./config.php file to point to your database.
Open the ./config.php file: vi /var/www/html/instance_name/config.php
Locate and update the dbconfig array with the information appropriate for your MySQL server as follows:
'dbconfig' => array ( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_Sugar_Cloud_to_On-Site/index.html |
d818b55b98cb-5 | 'dbconfig' => array (
'db_host_name' => 'localhost',
'db_host_instance' => 'SQLEXPRESS',
'db_user_name' => 'mysql_username',
'db_password' => 'mysql_password',
'db_name' => 'instance_name',
'db_type' => 'mysql',
'db_port' => '',
'db_manager' => 'MysqliManager',
),
Edit the config.php file and modify the following parameters:
site_url should be the URL of the instance on your server (e.g. https://www.mysugarinstance.com)
host_name should be the URL of the instance without the https protocol (e.g. www.mysugarinstance.com) | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_Sugar_Cloud_to_On-Site/index.html |
d818b55b98cb-6 | Modify the .htaccess file in the root directory of the instance.
Remove the following lines if they exist in the file:
#Added by operations to force SSL
RewriteEngine On
RewriteCond %{QUERY_STRING} !^entryPoint=WebToLeadCapture
RewriteCond %{HTTP:X-SSL-CLUSTER} !^od2$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
If your on-site deployment does not reside in the root of your domain (e.g. https://www.example.com/mysugar/), change the following line from:
RewriteBase /
to:
RewriteBase /mysugar/ | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_Sugar_Cloud_to_On-Site/index.html |
d818b55b98cb-7 | RewriteBase /
to:
RewriteBase /mysugar/
If you are migrating permanently to an on-site deployment, there are additional modifications that should be made to ensure full functionality for your instance of Sugar.To restore the ability to perform upgrades, open the ./config.php file and remove the following line: 'disable_uw_upload' => true,
To display the full-text search configuration options under Admin > Search, open the ./config.php file and remove the following line: 'hide_full_text_engine_config' => true,
To display the Sugar log settings under Admin > System Settings, open the ./config.php file and remove the following line: 'logger_visible' => false,
To bypass security checks when installing packages via Admin > Module Loader, open the ./config.php file and change the following line from:'packageScan' => true, | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_Sugar_Cloud_to_On-Site/index.html |
d818b55b98cb-8 | to: 'packageScan' => false,
To ensure full-text search functions properly, open the ./config.php file and modify the following lines to point to your ElasticSearch configuration:
'full_text_engine' => array (
'Elastic' => array (
'host' => '<your_elastic_search_host>',
'port' => '<your_elastic_search_port>',
),
),
Disable the SugarCloud Insights service as this is only available for SugarCloud instances. Open the ./config.php file and change 'enabled' => true, to 'enabled' => false, in the following array:'cloud_insight' =>
array (
'enabled' => true,
'url' => 'https://sugarcloud-insights.service.sugarcrm.com', | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_Sugar_Cloud_to_On-Site/index.html |
d818b55b98cb-9 | 'key' => '<insights key>',
),
Finally, please navigate to Admin > Repair and perform a "Quick Repair and Rebuild" to clear all cached elements from the SugarCloud instance.
You should now have a working version of your SugarCloud instance accessible from your local server.
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_Sugar_Cloud_to_On-Site/index.html |
b721ce93cd4d-0 | Migrating From On-Site to SugarCloud
Overview
The following article describes the process of migrating an on-site deployment to the SugarCloud environment.
Prerequisites
A few requirements must be met before an instance can be migrated to the SugarCloud environment:
The on-site deployment must be running MySQL. If you are using SQL Server or Oracle, you will need to speak with your Sugar Customer Advocate about data migration options.
The instance must be updated to a supported version of Sugar. Refer to the Managing Your Sugar Subscription article for information on determining your Sugar version. Once identified, you can check your version against our Supported Versions.
Migration
Once the above requirements have been met you are ready to migrate.
Case Portal | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_On-Site_to_On-Demand/index.html |
b721ce93cd4d-1 | Migration
Once the above requirements have been met you are ready to migrate.
Case Portal
Inform Sugar Support of your intention to migrate by opening a support case. They will provide you with an FTP site and a set of credentials so you can transfer your instance. Sugar Support will expect you to provide two files. One file will be an archive (zip, tar, etc.) containing all the files and folders of your Sugar instance. The second file will be an export of your SQL database; it is a good idea to archive the resulting SQL export as well.
Files and Folders
You should be aware of the location of your Sugar instance on your on-site server. If you do not, you can locate the path to your instance by navigating to Admin > Schedulers.
Once there, you should see something similar to this:
To Set Up Crontab | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_On-Site_to_On-Demand/index.html |
b721ce93cd4d-2 | Once there, you should see something similar to this:
To Set Up Crontab
Note: In order to run Sugar Schedulers, add the following line to the crontab file: * * * * * cd <path to sugar instance>; php -f cron.php > /dev/null 2>&1
Now that you have located the path to your Sugar instance, archive the entire contents of the Sugar root directory using the archive utility of your choice (zip, tar, WinZip, WinRar, 7zip, etc.). The Sugar root directory is the directory that contains the files config.php, cron.php, sugarcrm.log, and the folders custom, cache, and modules among others.
Database | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_On-Site_to_On-Demand/index.html |
b721ce93cd4d-3 | Database
The following describes how to export a MySQL database using the command line utility "mysqldump". If you prefer, you may choose to use a tool such as phpMyAdmin to export your database. The command to export a MySQL database is:
mysqldump -h localhost -u [MySQL user, e.g. root] -p[database password] [name of the database] > backup.sql
If you do not know the host, username, password, or database name you may refer to the "config.php" file of your Sugar instance. The "dbconfig" array in the "config.php" file contains all the required information. The example above showed the following "dbconfig" array:
'dbconfig' => array (
'db_host_name' => 'localhost',
'db_host_instance' => 'SQLEXPRESS', | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_On-Site_to_On-Demand/index.html |
b721ce93cd4d-4 | 'db_host_instance' => 'SQLEXPRESS',
'db_user_name' => 'sugarcrm',
'db_password' => 'MyP@ssword',
'db_name' => 'sugarcrm',
'db_type' => 'mysql',
),
Using this information we can rewrite the command:
mysqldump -h localhost -u sugarcrm -pMyP@ssword sugarcrm > backup.sql
Upload
Finally, upload the two files to the FTP site provided by the Sugar Support team. The instance will be deployed to the SugarCloud environment and a URL to the instance will be provided to you.
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_On-Site_to_On-Demand/index.html |
0a6a0d9c5731-0 | Migrating From a Broken Instance to a Clean Install
Overview
The following article describes the process of migrating a potentially broken instance to a clean install.
This is beneficial in the use case of corrupted core files. This will not correct issues caused by broken customizations.
Requirements
To migrate your instance to a clean install you will need to do the following:
Have full permissions to modify the system files.
Identify your Sugar version. Note: The version of your instance can be found by clicking the Help link in Sugar's footer or navigating to the About page from your user menu.Â
Once you have identified your Sugar version, you will need to download the full installer package of your Sugar version from your account's Downloads page.
If you are on 13.0.0 Pro, you must download the SugarPro-13.0.0.zip package or the migration will not work. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_a_Broken_Instance_to_a_clean_install/index.html |
0a6a0d9c5731-1 | Migrating to a New Instance
Make a complete backup of your broken instance. This includes both the filesystem and database.
Extract the contents of your downloaded Sugar package ( Sugar<Edition>-<Version>.zip ) to your web directory. This will be your clean Sugar directory that we will migrate your existing instance to.
You will then need to copy the following directories and files from your broken instance to the clean instance:
./config.php
./config_override.php (if it exists)
./custom/
./upload/
./cache/images/ - This is optional and contains the embedded emails displayed in the UI.
Note:Â If you are on a version prior to 6.4.0, you will also need to copy over the entire ./cache/ directory. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_a_Broken_Instance_to_a_clean_install/index.html |
0a6a0d9c5731-2 | Next, you will need to identify if you have any custom modules. These folders will reside in your ./modules/ directory and have a naming format of <key>_<module name>. You will need to copy these files to their corresponding directory in the clean instance you extracted in step 2.
Once the files have been moved to the clean instance, you can remove your old instances files and move the clean instance in its place. If you choose to move the instance to a new location on the server, you will need to update the $sugar_config['site_url'] parameter in your ./config.php and/or ./config_override.php files.
Reset your filesystem permissions.
Log into your instance as an administrator and navigate to Admin > Repair > Quick Repair and Rebuild.
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Migrating_From_a_Broken_Instance_to_a_clean_install/index.html |
860b27742655-0 | Importing Records
Covers the Sugar structure when migrating data into the application.
TopicsImporting Email AddressesRecommended approaches when Importing email addresses.
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Importing_Records/index.html |
5ff95bc38bb4-0 | Importing Email Addresses
Overview
Recommended approaches when Importing email addresses.
Importing via API
Sugar comes out of the box with an API that can be called from custom applications utilizing the REST interface. The API can be used to mass create and update records in Sugar with external data. For more information on the REST API in Sugar, please refer to the Web Services documentation.
Importing New Records
When importing new records into Sugar through the API, modules with relationships to email addresses can utilize the email1 field or the email link field to specify email addresses for a record.
Email1 Field | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Importing_Records/Importing_Email_Addresses/index.html |
5ff95bc38bb4-1 | Email1 Field
When using the email1 field, the default functionality is to import the email address specified as the primary address. Assuming the email address does not already exist in the database, the email address is then flagged as being valid and is not opted out. Using the /<module> POST endpoint, you can send the following JSON payload to create a contact record with a primary email address using the email1 field: POST URL: http://<site url>/rest/v10/Contacts
{
"first_name":"Rob",
"last_name":"Robertson",
"email1":"[email protected]"
}
Note: For importing multiple email addresses, you will need to use the email link field described below.
Email Link Field | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Importing_Records/Importing_Email_Addresses/index.html |
5ff95bc38bb4-2 | Email Link Field
When using the email link field, you can specify multiple email addresses to assign to the record. You may specify the following additional information regarding each email address being added:
invalid_email : Specify this email address as being invalid
opt_out : Specify this email address as being opted out
primary_address : Specify this email address as the primary
Using the /<module>Â POST endpoint, you can send the following JSON payload to create a contact record with multiple email addresses using the email link field: POST URL: http://<site url>/rest/v10/Contacts
{
"first_name":"Rob",
"last_name":"Robertson",
"email":[
{
"email_address":"[email protected]",
"primary_address":"1",
"invalid_email":"0", | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Importing_Records/Importing_Email_Addresses/index.html |
5ff95bc38bb4-3 | "primary_address":"1",
"invalid_email":"0",
"opt_out":"0"
},
{
"email_address":"[email protected]",
"primary_address":"0",
"invalid_email":"0",
"opt_out":"1"
}
]
}
For more information on the /<module>/:record POST endpoint, you can refer to your instance's help documentation found at:
http://<site url>/rest/v10/help
Or you can reference the <module> POST PHP example.
Updating Existing Records
When updating existing records in Sugar through the API, modules with relationships to email addresses can also utilize the email1 field or the email link field to specify email addresses for a record.
Email1 Field | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Importing_Records/Importing_Email_Addresses/index.html |
5ff95bc38bb4-4 | Email1 Field
When using the email1 field, the default functionality is to replace the existing email primary address. Assuming the email does not already exist in the database, the new email address is flagged as being valid and is not opted out. Using the /<module>/:record PUT endpoint, you can send the following JSON payload to update a contact records primary email address:
PUT URL: http://<site url>/rest/v10/Contacts/<record id>
{
"email1":"[email protected]"
}
Note: This will replace the current email address on the record with the new data. The old email address will no longer be associated with the record.
Email Link Field
When using the email link field, you can specify multiple email addresses to update the record with. You may specify the following additional information regarding each email address being added: | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Importing_Records/Importing_Email_Addresses/index.html |
5ff95bc38bb4-5 | invalid_email : Specify this email address as being invalid
opt_out : Specify this email address as being opted out
primary_address : Specify this email address as the primary
Using the /<module>/:record PUT endpoint, you can send the following JSON payload to update a contact record with multiple email addresses: PUT URL: http://<site url>/rest/v10/Contacts/<record id>
{
"email":[
{
"email_address":"[email protected]",
"primary_address":"1",
"invalid_email":"0",
"opt_out":"0"
},
{
"email_address":"[email protected]",
"primary_address":"0",
"invalid_email":"0", | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Importing_Records/Importing_Email_Addresses/index.html |
5ff95bc38bb4-6 | "primary_address":"0",
"invalid_email":"0",
"opt_out":"1"
}
]
}
For more information on the /<module>/:record PUT endpoint, you can refer to your instance's help documentation found at:
http://<site url>/rest/v10/help
Or you can reference the <module>/:record PUT PHP example.
Importing via Database
When importing records into Sugar directly via the database, it is important that you understand the data structure involved before loading data. Email addresses are not stored directly on the table for the module being imported in, but are related via the email_addr_bean_rel table.
The table structure for email addresses can be seen from the database via the following SQL statement:
SELECT
email_addr_bean_rel.bean_id, | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Importing_Records/Importing_Email_Addresses/index.html |
5ff95bc38bb4-7 | SELECT
email_addr_bean_rel.bean_id,
email_addr_bean_rel.bean_module,
email_addresses.email_address
FROM email_addr_bean_rel
INNER JOIN email_addresses
ON email_addresses.id = email_addr_bean_rel.email_address_id
AND email_addr_bean_rel.deleted = 0
WHERE email_addresses.deleted = 0;
Checking for Duplicates
Email addresses can become duplicated in Sugar from a variety of sources including API calls, imports, and from data entry. There are a few ways to have the system check for duplicate contact records, but not many of those methods work for checking email addresses for duplicates. The following section will demonstrate how to find and clean up duplicate email addresses using SQL. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Importing_Records/Importing_Email_Addresses/index.html |
5ff95bc38bb4-8 | The following SQL query can be used to locate if any email addresses are being used against more than one bean record within Sugar:
SELECT
email_addresses.email_address,
COUNT(*) AS email_address_count
FROM email_addr_bean_rel
INNER JOIN email_addresses
ON email_addresses.id = email_addr_bean_rel.email_address_id
AND email_addr_bean_rel.deleted = 0
WHERE email_addresses.deleted = 0
GROUP BY email_addresses.email_address
HAVING COUNT(*) > 1;
Note: If you convert a Lead record to a Contact record, both the Lead and the Contact will be related to the same Email Address and will return as having duplicates in this query. You can add the following line to the WHERE clause to filter the duplicate check down to only one bean type: | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Importing_Records/Importing_Email_Addresses/index.html |
5ff95bc38bb4-9 | AND email_addr_bean_rel.bean_module = 'Contacts'
Email addresses can not only be duplicated in the system but can occasionally be missing critical data. Each bean record with an email address assigned to it should have an email address designated the primary. The following query will locate any bean records that have at least one email address, where there is not an email address designated as the primary:
SELECT
email_addr_bean_rel.bean_module,
email_addr_bean_rel.bean_id,
COUNT(*) AS email_count,
COUNT(primary_email_addr_bean_rel.id) AS primary_email_count
FROM email_addr_bean_rel
LEFT JOIN email_addr_bean_rel primary_email_addr_bean_rel | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Importing_Records/Importing_Email_Addresses/index.html |
5ff95bc38bb4-10 | ON primary_email_addr_bean_rel.bean_module = email_addr_bean_rel.bean_module
AND primary_email_addr_bean_rel.bean_id = email_addr_bean_rel.bean_id
AND primary_email_addr_bean_rel.primary_address = '1'
AND primary_email_addr_bean_rel.deleted = '0'
WHERE email_addr_bean_rel.deleted = '0'
GROUP BY email_addr_bean_rel.bean_module,
email_addr_bean_rel.bean_id
HAVING primary_email_count < 1;
Removing Duplicates
If it is determined you have duplicate email addresses being used in your system, you can use the following query to clean up the records:
START TRANSACTION;
CREATE
TABLE email_addr_bean_rel_tmp | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Importing_Records/Importing_Email_Addresses/index.html |
5ff95bc38bb4-11 | CREATE
TABLE email_addr_bean_rel_tmp
SELECT
*
FROM email_addr_bean_rel
WHERE deleted = '0'
GROUP BY email_address_id,
bean_module,
bean_id
ORDER BY primary_address DESC;
TRUNCATE TABLE email_addr_bean_rel;
INSERT INTO email_addr_bean_rel
SELECT
*
FROM email_addr_bean_rel_tmp;
SELECT
COUNT(*) AS repetitions,
date_modified,
bean_id,
bean_module
FROM email_addr_bean_rel
WHERE deleted = '0'
GROUP BY bean_id,
bean_module,
email_address_id
HAVING repetitions > 1;
COMMIT;
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Migration/Importing_Records/Importing_Email_Addresses/index.html |
909b56d792ff-0 | ExternalResourceClient
Overview
In Sugar 12.1, ExternalResourceClient was introduced to replace cURL. This has also been backported to all supported versions of Sugar. Therefore any apps or integrations for Sugar that use a Module Loadable Package (MLP) that includes any of the PHP curl_*, socket_*, or stream_* functions will need to change to use the ExternalResourceClient lib.
Self-Signed Certificates
ExternalResourceClient is designed to be as secure as possible. We will not support disabling the check for authenticity of the peer's certificate as you could in cURL with using the CURLOPT_SSL_VERIFYPEER option. This is not a security best practice and is therefore not allowed in the new client. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-1 | If your target URL has an invalid or self-signed certificate, you can benefit from using Let's Encrypt. Let's Encrypt is a free, automated, and open Certificate Authority (CA) that makes it possible to set up an HTTPS server and have it automatically obtain a browser-trusted certificate without any human intervention. You can get started here.
TLS Mutual Authentication | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-2 | TLS Mutual Authentication
ExternalResourceClient supports TLS mutual authentication where it ensures that the parties at each end of a network connection are who they claim to be by verifying that they both have the correct private key. The information within their respective TLS certificates provides additional verification is designed to be as secure as possible. In cURL it could be achieved using the curl_setopt($ch, CURLOPT_SSLCERT, <CERT_FILE>); and curl_setopt($ch, CURLOPT_SSLKEY, <KEY_FILE>); options.
ExternalResourceClient can be configured with the following options or any of those available in the PHP SSL Context options.: | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-3 | local_cert - Path to local certificate file on filesystem. It must be a PEM encoded file which contains your certificate and private key. It can optionally contain the certificate chain of issuers. The private key also may be contained in a separate file specified by local_pk.
local_pk - Path to local private key file on filesystem in case of separate files for certificate (local_cert) and private key.
<?php
$client = (new ExternalResourceClient())
->setSslContextOptions([
'local_cert' => '<CERT_FILE>', //CURLOPT_SSLCERT analogue
'local_pk' => '<KEY_FILE>', // CURLOPT_SSLKEY
]);
Â
IP vs Domain/Hostnames via DNS | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-4 | ]);
Â
IP vs Domain/Hostnames via DNS
ExternalResourceClient does not support using an IP address in your URL. Editing /etc/hosts on your server is a very easy and fast way of accomplishing this, but if that is not an option and you have a proper DNS server configured, you can use one of the following articles to help you understand what DNS is and how you can configure them in different OSs and infrastructures.
Build your own DNS server on Linux
DNS Configuration: Everything You Need to Know
How to Setup DNS Server on Windows Server 2012
DNS Over HTTPS Configuration | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-5 | How to Setup DNS Server on Windows Server 2012
DNS Over HTTPS Configuration
The security.use_doh configuration setting enables remote Domain Name System (DNS) resolution via the HTTPS protocol. A goal of the method is to increase user privacy and security by preventing eavesdropping and manipulation of DNS data by man-in-the-middle attacks by using the HTTPS protocol to encrypt the data between the DoH (DNS over HTTPS) client and the DoH-based DNS resolver.
When enabled, it will use dns.google (8.8.4.4) to resolve hostnames.
For more details on the security.use_doh configuration setting, see the Core Settings page.
Local Endpoints
If you do not know what server-side request forgery (SSRF) is, please refer to this detailed explanation and examples of how an attacker can reach your local network using malicious HTTP requests. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-6 | ExternalResourceClient prevents this type of attack by taking the resolved IP from your URL and checking against a Sugar Config $sugar_config['security']['private_ips'] array list.
This list contains a wide range of internal IPs blocked by default [ '10.0.0.0|10.255.255.255', '172.16.0.0|172.31.255.255', '192.168.0.0|192.168.255.255', '169.254.0.0|169.254.255.255', '127.0.0.0|127.255.255.255'] .
For example, if your URL is http://an-internal-url/api/get and "an-internal-url" resolves to an IP 10.0.0.87, it will throw an exception because it is within the range of your config. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-7 | Add your critical IP ranges to this config so no attacker will get to sensitive IPs through ExternalResourceClient's HTTP Request.
Sugar Proxy
To get proxy settings, ExternalResourceClient relies on Administration::getSettings('proxy'). This utility queries Sugar's infrastructure (cache or DB) to retrieve those settings, therefore it needs to be bootstrapped into SugarCRM.
In the case of MLPs that use standard modules via the web, you don't need to manually bootstrap SugarCRM, so you may use ExternalResourceClient in your methods without requiring entryPoint.php
If you are writing a CLI script, you must include SugarCRM entryPoint.php:
<?php
if (!defined('sugarEntry')) {
define('sugarEntry', true);
}
define('ENTRY_POINT_TYPE', 'api');
require_once 'include/entryPoint.php'; | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-8 | require_once 'include/entryPoint.php';
?>
Test your customization
You can easily test your package by enabling PackageScanner checks in the supported versions for now ($sugar_config['moduleInstaller']['enableEnhancedModuleChecks'] = true), remember, it comes disabled by default in 12.1.
If your code doesn't go through PackageScanner, it will not be enforced, that's the premise we're working with.
Examples of Replacing cURL
The below examples can be used as a guideline for replacing your current cURL code with ExternalResourceClient.
You must import this client and its exceptions (if needed) from:
<?php
use Sugarcrm\Sugarcrm\Security\HttpClient\ExternalResourceClient;
use Sugarcrm\Sugarcrm\Security\HttpClient\RequestException;
HTTP GET | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-9 | HTTP GET
The following code snippet provides you with a code replacement from cURL GET to ExternalResourceClient.
Before:
// cURL GET
$ch = curl_init();
$url = 'https://httpbin.org/get';
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 60,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2TLS,
));
$response = curl_exec($ch); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-10 | ));
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$errorNo = curl_errno($ch);
$error = curl_error($ch);
if ($errorNo !== 0) {
$GLOBALS['log']->log("fatal", "curl error ($errorNo): $error");
throw new \SugarApiExceptionError("curl error ($errorNo): $error");
}
curl_close($ch);
if ($httpCode === 0 || $httpCode >= 400) {
$GLOBALS['log']->log("fatal", "Error message: $error");
throw new \SugarApiException($error, null, null, $httpCode ? $httpCode : 500);
}
echo $response;
After: | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-11 | }
echo $response;
After:
// ExternalResourceClient GET
try {
// Set timeout to 60 seconds and 10 max redirects
$response = (new ExternalResourceClient(60, 10))->get($url);
} catch (RequestException $e) {
$GLOBALS['log']->log('fatal', 'Error: ' . $e->getMessage());
throw new \SugarApiExceptionError($e->getMessage());
}
$httpCode = $response->getStatusCode();
if ($httpCode >= 400) {
$GLOBALS['log']->log("fatal", "Request failed with status: " . $httpCode);
throw new \SugarApiException("Request failed with status: " . $httpCode, null, null, $httpCode);
}
echo $response->getBody()->getContents(); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-12 | }
echo $response->getBody()->getContents();
HTTP POST
The following code snippet provides you with a code replacement from cURL POST to ExternalResourceClient.
Before:
// cURL POST JSON
$url = 'https://httpbin.org/post';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array ("Content-Type: application/json")); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-13 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['foo' => 'bar']));
$response = curl_exec($ch);
curl_close($ch);
$parsed = !empty($response) ? json_decode($response, true) : null;
var_dump($parsed);
After:
// ExternalResourceClient POST JSON
try {
$response = (new ExternalResourceClient())->post($url, json_encode(['foo' => 'bar']), ['Content-Type' => "application/json"]);
} catch (RequestException $e) {
throw new \SugarApiExceptionError($e->getMessage());
}
$parsed = !empty($response) ? json_decode($response->getBody()->getContents(), true) : null; | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-14 | var_dump($parsed);
Authenticated Endpoints (CURLOPT_USERPWD)
The following code snippet provides you with a code replacement from cURL to ExternalResourceClient passing authentication params.
Before:
$username = 'foo';
$password = 'bar';
$url = 'https://httpbin.org/basic-auth/{$username}/{$password}';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERPWD, $username . $password);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-15 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['foo' => 'bar']));
$response = curl_exec($ch);
curl_close($ch);
$parsed = !empty($response) ? json_decode($response, true) : null;
var_dump($parsed);
After:
$username = 'foo';
$password = 'bar';
$auth = base64_encode( "{$username}:{$password}" );
//Passing custom 'Authorization' header
// try + catch is omitted for brevity
$response = (new ExternalResourceClient())->get("https://httpbin.org/basic-auth/{$username}/{$password}", [
'Authorization' => 'Basic ' . $auth,
]); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-16 | 'Authorization' => 'Basic ' . $auth,
]);
echo $response->getBody()->getContents();
// OR the same by using user:[email protected] URL format
// try + catch is omitted for brevity
$response = (new ExternalResourceClient())->get("https://{$username}:{$password}@httpbin.org/basic-auth/{$username}/{$password}");
echo $response->getBody()->getContents();
Stream
The following code snippet provides you with a code replacement from stream to ExternalResourceClient.
Before:
<?php
// Sending GET
if ($stream = fopen('https://httpbin.org/get', 'r')) {
echo stream_get_contents($stream);
}
// Sending POST
$options = [
'http' => [ | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-17 | }
// Sending POST
$options = [
'http' => [
'method' => 'POST',
'header' => ["Content-Type: application/x-www-form-urlencoded"],
'content' => http_build_query(['fieldName' => 'value', 'fieldName2' => 'another value']),
'ignore_errors' => true,
],
];
$context = stream_context_create($options);
if ($stream = fopen('https://httpbin.org/post', 'r', false, $context)) {
echo stream_get_contents($stream);
}
After:
// Using ExtenalResourceClient
// GET
echo (new ExternalResourceClient())
->get('https://httpbin.org/get')
->getBody()
->getContents();
// POST | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-18 | ->getBody()
->getContents();
// POST
echo (new ExternalResourceClient())
->post(
'https://httpbin.org/post',
['fieldName' => 'value', 'fieldName2' => 'another value']
)
->getBody()
->getContents();
Socket
The following code snippet provides you with a code replacement from socket to ExternalResourceClient.
Before:
<?php
// Sending GET
$fp = fsockopen("httpbin.org", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)\n";
} else {
$out = "GET /get HTTP/1.1\r\n";
$out .= "Host: httpbin.org\r\n"; | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-19 | $out .= "Host: httpbin.org\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
// Sending POST
$fp = fsockopen("httpbin.org", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)\n";
} else {
$postData = http_build_query(['fieldName' => 'value', 'fieldName2' => 'another value']);
$out = "POST /post HTTP/1.1\r\n";
$out .= "Host: httpbin.org\r\n"; | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
909b56d792ff-20 | $out .= "Host: httpbin.org\r\n";
$out .= "Content-type: application/x-www-form-urlencoded\r\n";
$out .= "Content-length: " . strlen($postData) . "\r\n";
$out .= "Connection: Close\r\n\r\n";
$out .= "{$postData}\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
After:
// Using ExtenalResourceClient
// GET
echo (new ExternalResourceClient())
->get('http://httpbin.org/get')
->getBody()
->getContents();
// POST | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.