This repository has been archived by the owner on Oct 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Query Options 2
mattkol edited this page Dec 18, 2016
·
7 revisions
This sample usage shows how to read "Leads" module entity collection data with query. For more request options make changes to the [Options parameter](Request Options).
This implements the get_entry_list SugarCRM REST API method setting the query parameter.
using SugarRestSharp;
string url = "http://191.101.224.189/sugar/service/v4_1/rest.php";
string username = "will";
string password = "will";
var client = new SugarRestClient(url, username, password);
var request = new SugarRestRequest(RequestType.BulkRead);
List<string> selectedFields = new List<string>();
selectedFields.Add("id");
selectedFields.Add("name");
selectedFields.Add("modified_by_name");
request.Options.SelectFields = selectedFields;
// Set query
request.Options.Query = "leads.id IN('10d82d59-08eb-8f0d-28e0-5777b57af47c', '12037cd0-ead2-402e-e1d0-5777b5dfb965', '13d4109d-c5ca-7dd1-99f1-5777b57ef30f', '14c136e5-1a67-eeba-581c-5777b5c8c463', '14e4825e-9573-4d75-2dbe-5777b5b7ee85', '1705b33a-3fad-aa70-77ef-5777b5b081f1', '171c1d8b-e34f-3a1f-bef7-5777b5ecc823', '174a8fc4-56e6-3471-46d8-5777b565bf5b', '17c9c496-90a1-02f5-87bd-5777b51ab086', '1d210352-7a1f-2c5d-04ae-5777b5a3312f')";
SugarRestResponse response = await client.ExecuteAsync<Lead>(request);
List<Lead> leads = (List<Lead>)response.Data
[
{
"modified_by_name": "Will Westin",
"id": "10d82d59-08eb-8f0d-28e0-5777b57af47c",
"name": "Howard Fricks"
},
{
"modified_by_name": "Will Westin",
"id": "12037cd0-ead2-402e-e1d0-5777b5dfb965",
"name": "Benny Berens"
},
{
"modified_by_name": "Will Westin",
"id": "13d4109d-c5ca-7dd1-99f1-5777b57ef30f",
"name": "Carlene Eickhoff"
},
{
"modified_by_name": "Administrator",
"id": "14c136e5-1a67-eeba-581c-5777b5c8c463",
"name": "Gaylord Amato"
},
{
"modified_by_name": "Administrator",
"id": "14e4825e-9573-4d75-2dbe-5777b5b7ee85",
"name": "Stevie Poteat"
},
{
"modified_by_name": "Administrator",
"id": "1705b33a-3fad-aa70-77ef-5777b5b081f1",
"name": "Antony Vierra"
},
{
"modified_by_name": "Administrator",
"id": "171c1d8b-e34f-3a1f-bef7-5777b5ecc823",
"name": "Josef Monaco"
},
{
"modified_by_name": "Administrator",
"id": "174a8fc4-56e6-3471-46d8-5777b565bf5b",
"name": "Eldridge Seese"
},
{
"modified_by_name": "Administrator",
"id": "17c9c496-90a1-02f5-87bd-5777b51ab086",
"name": "Trevor Fenley"
},
{
"modified_by_name": "Administrator",
"id": "1d210352-7a1f-2c5d-04ae-5777b5a3312f",
"name": "Lynwood Westbury"
}
]
{
"resource": "",
"parameters": [
{
"name": "method",
"value": "get_entry_list",
"type": "GetOrPost"
},
{
"name": "input_type",
"value": "json",
"type": "GetOrPost"
},
{
"name": "response_type",
"value": "json",
"type": "GetOrPost"
},
{
"name": "rest_data",
"value": "{\"session\":\"utcbtikvae70rur2rcp2lm3uv6\",\"module_name\":\"Leads\",\"query\":\" leads.id IN('10d82d59-08eb-8f0d-28e0-5777b57af47c', '12037cd0-ead2-402e-e1d0-5777b5dfb965', '13d4109d-c5ca-7dd1-99f1-5777b57ef30f', '14c136e5-1a67-eeba-581c-5777b5c8c463', '14e4825e-9573-4d75-2dbe-5777b5b7ee85', '1705b33a-3fad-aa70-77ef-5777b5b081f1', '171c1d8b-e34f-3a1f-bef7-5777b5ecc823', '174a8fc4-56e6-3471-46d8-5777b565bf5b', '17c9c496-90a1-02f5-87bd-5777b51ab086', '1d210352-7a1f-2c5d-04ae-5777b5a3312f') \",\"order_by\":\"\",\"offset\":0,\"select_fields\":[\"id\",\"name\",\"modified_by_name\"],\"link_name_to_fields_array\":\"\",\"max_results\":100,\"deleted\":0,\"favorites\":false}",
"type": "GetOrPost"
},
{
"name": "Accept",
"value": "application\/json, application\/xml, text\/json, text\/x-json, text\/javascript, text\/xml",
"type": "HttpHeader"
}
],
"method": "POST",
"uri": "http:\/\/191.101.224.189\/sugar\/service\/v4_1\/rest.php"
}
{
"statusCode": 200,
"content": "{\"result_count\":10,\"total_count\":\"10\",\"next_offset\":10,\"entry_list\":[{\"id\":\"10d82d59-08eb-8f0d-28e0-5777b57af47c\",\"module_name\":\"Leads\",\"name_value_list\":{\"modified_by_name\":{\"name\":\"modified_by_name\",\"value\":\"Will Westin\"},\"id\":{\"name\":\"id\",\"value\":\"10d82d59-08eb-8f0d-28e0-5777b57af47c\"},\"name\":{\"name\":\"name\",\"value\":\"Howard Fricks\"}}},{\"id\":\"12037cd0-ead2-402e-e1d0-5777b5dfb965\",\"module_name\":\"Leads\",\"name_value_list\":{\"modified_by_name\":{\"name\":\"modified_by_name\",\"value\":\"Will Westin\"},\"id\":{\"name\":\"id\",\"value\":\"12037cd0-ead2-402e-e1d0-5777b5dfb965\"},\"name\":{\"name\":\"name\",\"value\":\"Benny Berens\"}}},{\"id\":\"13d4109d-c5ca-7dd1-99f1-5777b57ef30f\",\"module_name\":\"Leads\",\"name_value_list\":{\"modified_by_name\":{\"name\":\"modified_by_name\",\"value\":\"Will Westin\"},\"id\":{\"name\":\"id\",\"value\":\"13d4109d-c5ca-7dd1-99f1-5777b57ef30f\"},\"name\":{\"name\":\"name\",\"value\":\"Carlene Eickhoff\"}}},{\"id\":\"14c136e5-1a67-eeba-581c-5777b5c8c463\",\"module_name\":\"Leads\",\"name_value_list\":{\"modified_by_name\":{\"name\":\"modified_by_name\",\"value\":\"Administrator\"},\"id\":{\"name\":\"id\",\"value\":\"14c136e5-1a67-eeba-581c-5777b5c8c463\"},\"name\":{\"name\":\"name\",\"value\":\"Gaylord Amato\"}}},{\"id\":\"14e4825e-9573-4d75-2dbe-5777b5b7ee85\",\"module_name\":\"Leads\",\"name_value_list\":{\"modified_by_name\":{\"name\":\"modified_by_name\",\"value\":\"Administrator\"},\"id\":{\"name\":\"id\",\"value\":\"14e4825e-9573-4d75-2dbe-5777b5b7ee85\"},\"name\":{\"name\":\"name\",\"value\":\"Stevie Poteat\"}}},{\"id\":\"1705b33a-3fad-aa70-77ef-5777b5b081f1\",\"module_name\":\"Leads\",\"name_value_list\":{\"modified_by_name\":{\"name\":\"modified_by_name\",\"value\":\"Administrator\"},\"id\":{\"name\":\"id\",\"value\":\"1705b33a-3fad-aa70-77ef-5777b5b081f1\"},\"name\":{\"name\":\"name\",\"value\":\"Antony Vierra\"}}},{\"id\":\"171c1d8b-e34f-3a1f-bef7-5777b5ecc823\",\"module_name\":\"Leads\",\"name_value_list\":{\"modified_by_name\":{\"name\":\"modified_by_name\",\"value\":\"Administrator\"},\"id\":{\"name\":\"id\",\"value\":\"171c1d8b-e34f-3a1f-bef7-5777b5ecc823\"},\"name\":{\"name\":\"name\",\"value\":\"Josef Monaco\"}}},{\"id\":\"174a8fc4-56e6-3471-46d8-5777b565bf5b\",\"module_name\":\"Leads\",\"name_value_list\":{\"modified_by_name\":{\"name\":\"modified_by_name\",\"value\":\"Administrator\"},\"id\":{\"name\":\"id\",\"value\":\"174a8fc4-56e6-3471-46d8-5777b565bf5b\"},\"name\":{\"name\":\"name\",\"value\":\"Eldridge Seese\"}}},{\"id\":\"17c9c496-90a1-02f5-87bd-5777b51ab086\",\"module_name\":\"Leads\",\"name_value_list\":{\"modified_by_name\":{\"name\":\"modified_by_name\",\"value\":\"Administrator\"},\"id\":{\"name\":\"id\",\"value\":\"17c9c496-90a1-02f5-87bd-5777b51ab086\"},\"name\":{\"name\":\"name\",\"value\":\"Trevor Fenley\"}}},{\"id\":\"1d210352-7a1f-2c5d-04ae-5777b5a3312f\",\"module_name\":\"Leads\",\"name_value_list\":{\"modified_by_name\":{\"name\":\"modified_by_name\",\"value\":\"Administrator\"},\"id\":{\"name\":\"id\",\"value\":\"1d210352-7a1f-2c5d-04ae-5777b5a3312f\"},\"name\":{\"name\":\"name\",\"value\":\"Lynwood Westbury\"}}}],\"relationship_list\":[]}",
"headers": [
{
"Name": "Pragma",
"Value": "no-cache",
"Type": 3,
"ContentType": null
},
{
"Name": "Content-Length",
"Value": "2812",
"Type": 3,
"ContentType": null
},
{
"Name": "Cache-Control",
"Value": "no-store, no-cache, must-revalidate, post-check=0, pre-check=0",
"Type": 3,
"ContentType": null
},
{
"Name": "Content-Type",
"Value": "application\/json; charset=UTF-8",
"Type": 3,
"ContentType": null
},
{
"Name": "Date",
"Value": "Sun, 18 Dec 2016 13:42:16 GMT",
"Type": 3,
"ContentType": null
},
{
"Name": "Expires",
"Value": "Thu, 19 Nov 1981 08:52:00 GMT",
"Type": 3,
"ContentType": null
},
{
"Name": "Set-Cookie",
"Value": "PHPSESSID=utcbtikvae70rur2rcp2lm3uv6; path=\/",
"Type": 3,
"ContentType": null
},
{
"Name": "Server",
"Value": "Apache\/2.4.7 (Ubuntu)",
"Type": 3,
"ContentType": null
},
{
"Name": "X-Powered-By",
"Value": "PHP\/5.5.9-1ubuntu4.17",
"Type": 3,
"ContentType": null
}
],
"responseUri": "http:\/\/191.101.224.189\/sugar\/service\/v4_1\/rest.php",
"errorMessage": null
}
SugarRestSharp
- Home
- Request
- Request Types
- Request Options
- Response
- Read Module By Id
- Read Module Collection By Page
- Read Module Collection
- Create Module
- Create Module Collection
- Update Module
- Update Module Collection
- Delete Module
- Linked Modules 1
- Linked Modules 2
- Linked Modules 3
- Query Options 1
- Query Options 2
- Query Options 3