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 3
mattkol edited this page Dec 18, 2016
·
5 revisions
This sample usage shows how to read "Accounts" module entity collection data with query. Both "query" and "query predicates" as set, but the predicates are ignored. 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);
request.Options.Query = "accounts.name = 'Air Safety Inc' ";
request.Options.QueryPredicates = new List<QueryPredicate>();
request.Options.QueryPredicates.Add(new QueryPredicate(nameof(Account.Name), QueryOperator.Equal, "General Electric USA, Inc"));
SugarRestResponse response = await client.ExecuteAsync<Account>(request);
List<Account> accounts = (List<Account>) response.Data;
[
{
"assigned_user_name": "Sarah Smith",
"modified_by_name": "Administrator",
"created_by_name": "Administrator",
"id": "481407cb-28b7-ab8f-28f0-5777b598e42e",
"name": "Air Safety Inc",
"date_entered": "2016-07-02 12:36:44",
"date_modified": "2016-07-02 12:36:44",
"modified_user_id": "1",
"created_by": "1",
"description": "",
"deleted": "0",
"assigned_user_id": "seed_sarah_id",
"account_type": "Customer",
"industry": "Education",
"annual_revenue": "",
"phone_fax": "",
"billing_address_street": "123 Anywhere Street",
"billing_address_street_2": "",
"billing_address_street_3": "",
"billing_address_street_4": "",
"billing_address_city": "Sunnyvale",
"billing_address_state": "CA",
"billing_address_postalcode": "71939",
"billing_address_country": "USA",
"rating": "",
"phone_office": "(604) 049-5766",
"phone_alternate": "",
"website": "www.kidsales.name",
"ownership": "",
"employees": "",
"ticker_symbol": "",
"shipping_address_street": "123 Anywhere Street",
"shipping_address_street_2": "",
"shipping_address_street_3": "",
"shipping_address_street_4": "",
"shipping_address_city": "Sunnyvale",
"shipping_address_state": "CA",
"shipping_address_postalcode": "71939",
"shipping_address_country": "USA",
"email1": "beans.dev.qa@example.net",
"email_addresses_non_primary": "",
"parent_id": "",
"sic_code": "",
"parent_name": "",
"email_opt_out": "0",
"invalid_email": "0",
"email": "",
"campaign_id": "",
"campaign_name": ""
},
{
"assigned_user_name": "Sarah Smith",
"modified_by_name": "Administrator",
"created_by_name": "Administrator",
"id": "6b1d1ada-00af-1a47-73fd-5777b548a6a2",
"name": "Air Safety Inc",
"date_entered": "2016-07-02 12:36:44",
"date_modified": "2016-07-02 12:36:44",
"modified_user_id": "1",
"created_by": "1",
"description": "",
"deleted": "0",
"assigned_user_id": "seed_sarah_id",
"account_type": "Customer",
"industry": "Telecommunications",
"annual_revenue": "",
"phone_fax": "",
"billing_address_street": "48920 San Carlos Ave",
"billing_address_street_2": "",
"billing_address_street_3": "",
"billing_address_street_4": "",
"billing_address_city": "Salt Lake City",
"billing_address_state": "CA",
"billing_address_postalcode": "10029",
"billing_address_country": "USA",
"rating": "",
"phone_office": "(839) 074-3293",
"phone_alternate": "",
"website": "www.salesqa.tw",
"ownership": "",
"employees": "",
"ticker_symbol": "",
"shipping_address_street": "48920 San Carlos Ave",
"shipping_address_street_2": "",
"shipping_address_street_3": "",
"shipping_address_street_4": "",
"shipping_address_city": "Salt Lake City",
"shipping_address_state": "CA",
"shipping_address_postalcode": "10029",
"shipping_address_country": "USA",
"email1": "sales.im.qa@example.biz",
"email_addresses_non_primary": "",
"parent_id": "",
"sic_code": "",
"parent_name": "",
"email_opt_out": "0",
"invalid_email": "0",
"email": "",
"campaign_id": "",
"campaign_name": ""
}
]
{
"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\":\"1l112qlpnupq7okfilru3nfft4\",\"module_name\":\"Accounts\",\"query\":\" accounts.name = 'Air Safety Inc' \",\"order_by\":\"\",\"offset\":0,\"select_fields\":[],\"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\":2,\"total_count\":\"2\",\"next_offset\":2,\"entry_list\":[{\"id\":\"481407cb-28b7-ab8f-28f0-5777b598e42e\",\"module_name\":\"Accounts\",\"name_value_list\":{\"assigned_user_name\":{\"name\":\"assigned_user_name\",\"value\":\"Sarah Smith\"},\"modified_by_name\":{\"name\":\"modified_by_name\",\"value\":\"Administrator\"},\"created_by_name\":{\"name\":\"created_by_name\",\"value\":\"Administrator\"},\"id\":{\"name\":\"id\",\"value\":\"481407cb-28b7-ab8f-28f0-5777b598e42e\"},\"name\":{\"name\":\"name\",\"value\":\"Air Safety Inc\"},\"date_entered\":{\"name\":\"date_entered\",\"value\":\"2016-07-02 12:36:44\"},\"date_modified\":{\"name\":\"date_modified\",\"value\":\"2016-07-02 12:36:44\"},\"modified_user_id\":{\"name\":\"modified_user_id\",\"value\":\"1\"},\"created_by\":{\"name\":\"created_by\",\"value\":\"1\"},\"description\":{\"name\":\"description\",\"value\":\"\"},\"deleted\":{\"name\":\"deleted\",\"value\":\"0\"},\"assigned_user_id\":{\"name\":\"assigned_user_id\",\"value\":\"seed_sarah_id\"},\"account_type\":{\"name\":\"account_type\",\"value\":\"Customer\"},\"industry\":{\"name\":\"industry\",\"value\":\"Education\"},\"annual_revenue\":{\"name\":\"annual_revenue\",\"value\":\"\"},\"phone_fax\":{\"name\":\"phone_fax\",\"value\":\"\"},\"billing_address_street\":{\"name\":\"billing_address_street\",\"value\":\"123 Anywhere Street\"},\"billing_address_street_2\":{\"name\":\"billing_address_street_2\",\"value\":\"\"},\"billing_address_street_3\":{\"name\":\"billing_address_street_3\",\"value\":\"\"},\"billing_address_street_4\":{\"name\":\"billing_address_street_4\",\"value\":\"\"},\"billing_address_city\":{\"name\":\"billing_address_city\",\"value\":\"Sunnyvale\"},\"billing_address_state\":{\"name\":\"billing_address_state\",\"value\":\"CA\"},\"billing_address_postalcode\":{\"name\":\"billing_address_postalcode\",\"value\":\"71939\"},\"billing_address_country\":{\"name\":\"billing_address_country\",\"value\":\"USA\"},\"rating\":{\"name\":\"rating\",\"value\":\"\"},\"phone_office\":{\"name\":\"phone_office\",\"value\":\"(604) 049-5766\"},\"phone_alternate\":{\"name\":\"phone_alternate\",\"value\":\"\"},\"website\":{\"name\":\"website\",\"value\":\"www.kidsales.name\"},\"ownership\":{\"name\":\"ownership\",\"value\":\"\"},\"employees\":{\"name\":\"employees\",\"value\":\"\"},\"ticker_symbol\":{\"name\":\"ticker_symbol\",\"value\":\"\"},\"shipping_address_street\":{\"name\":\"shipping_address_street\",\"value\":\"123 Anywhere Street\"},\"shipping_address_street_2\":{\"name\":\"shipping_address_street_2\",\"value\":\"\"},\"shipping_address_street_3\":{\"name\":\"shipping_address_street_3\",\"value\":\"\"},\"shipping_address_street_4\":{\"name\":\"shipping_address_street_4\",\"value\":\"\"},\"shipping_address_city\":{\"name\":\"shipping_address_city\",\"value\":\"Sunnyvale\"},\"shipping_address_state\":{\"name\":\"shipping_address_state\",\"value\":\"CA\"},\"shipping_address_postalcode\":{\"name\":\"shipping_address_postalcode\",\"value\":\"71939\"},\"shipping_address_country\":{\"name\":\"shipping_address_country\",\"value\":\"USA\"},\"email1\":{\"name\":\"email1\",\"value\":\"beans.dev.qa@example.net\"},\"email_addresses_non_primary\":{\"name\":\"email_addresses_non_primary\",\"value\":\"\"},\"parent_id\":{\"name\":\"parent_id\",\"value\":\"\"},\"sic_code\":{\"name\":\"sic_code\",\"value\":\"\"},\"parent_name\":{\"name\":\"parent_name\",\"value\":\"\"},\"email_opt_out\":{\"name\":\"email_opt_out\",\"value\":\"0\"},\"invalid_email\":{\"name\":\"invalid_email\",\"value\":\"0\"},\"email\":{\"name\":\"email\",\"value\":\"\"},\"campaign_id\":{\"name\":\"campaign_id\",\"value\":\"\"},\"campaign_name\":{\"name\":\"campaign_name\",\"value\":\"\"}}},{\"id\":\"6b1d1ada-00af-1a47-73fd-5777b548a6a2\",\"module_name\":\"Accounts\",\"name_value_list\":{\"assigned_user_name\":{\"name\":\"assigned_user_name\",\"value\":\"Sarah Smith\"},\"modified_by_name\":{\"name\":\"modified_by_name\",\"value\":\"Administrator\"},\"created_by_name\":{\"name\":\"created_by_name\",\"value\":\"Administrator\"},\"id\":{\"name\":\"id\",\"value\":\"6b1d1ada-00af-1a47-73fd-5777b548a6a2\"},\"name\":{\"name\":\"name\",\"value\":\"Air Safety Inc\"},\"date_entered\":{\"name\":\"date_entered\",\"value\":\"2016-07-02 12:36:44\"},\"date_modified\":{\"name\":\"date_modified\",\"value\":\"2016-07-02 12:36:44\"},\"modified_user_id\":{\"name\":\"modified_user_id\",\"value\":\"1\"},\"created_by\":{\"name\":\"created_by\",\"value\":\"1\"},\"description\":{\"name\":\"description\",\"value\":\"\"},\"deleted\":{\"name\":\"deleted\",\"value\":\"0\"},\"assigned_user_id\":{\"name\":\"assigned_user_id\",\"value\":\"seed_sarah_id\"},\"account_type\":{\"name\":\"account_type\",\"value\":\"Customer\"},\"industry\":{\"name\":\"industry\",\"value\":\"Telecommunications\"},\"annual_revenue\":{\"name\":\"annual_revenue\",\"value\":\"\"},\"phone_fax\":{\"name\":\"phone_fax\",\"value\":\"\"},\"billing_address_street\":{\"name\":\"billing_address_street\",\"value\":\"48920 San Carlos Ave\"},\"billing_address_street_2\":{\"name\":\"billing_address_street_2\",\"value\":\"\"},\"billing_address_street_3\":{\"name\":\"billing_address_street_3\",\"value\":\"\"},\"billing_address_street_4\":{\"name\":\"billing_address_street_4\",\"value\":\"\"},\"billing_address_city\":{\"name\":\"billing_address_city\",\"value\":\"Salt Lake City\"},\"billing_address_state\":{\"name\":\"billing_address_state\",\"value\":\"CA\"},\"billing_address_postalcode\":{\"name\":\"billing_address_postalcode\",\"value\":\"10029\"},\"billing_address_country\":{\"name\":\"billing_address_country\",\"value\":\"USA\"},\"rating\":{\"name\":\"rating\",\"value\":\"\"},\"phone_office\":{\"name\":\"phone_office\",\"value\":\"(839) 074-3293\"},\"phone_alternate\":{\"name\":\"phone_alternate\",\"value\":\"\"},\"website\":{\"name\":\"website\",\"value\":\"www.salesqa.tw\"},\"ownership\":{\"name\":\"ownership\",\"value\":\"\"},\"employees\":{\"name\":\"employees\",\"value\":\"\"},\"ticker_symbol\":{\"name\":\"ticker_symbol\",\"value\":\"\"},\"shipping_address_street\":{\"name\":\"shipping_address_street\",\"value\":\"48920 San Carlos Ave\"},\"shipping_address_street_2\":{\"name\":\"shipping_address_street_2\",\"value\":\"\"},\"shipping_address_street_3\":{\"name\":\"shipping_address_street_3\",\"value\":\"\"},\"shipping_address_street_4\":{\"name\":\"shipping_address_street_4\",\"value\":\"\"},\"shipping_address_city\":{\"name\":\"shipping_address_city\",\"value\":\"Salt Lake City\"},\"shipping_address_state\":{\"name\":\"shipping_address_state\",\"value\":\"CA\"},\"shipping_address_postalcode\":{\"name\":\"shipping_address_postalcode\",\"value\":\"10029\"},\"shipping_address_country\":{\"name\":\"shipping_address_country\",\"value\":\"USA\"},\"email1\":{\"name\":\"email1\",\"value\":\"sales.im.qa@example.biz\"},\"email_addresses_non_primary\":{\"name\":\"email_addresses_non_primary\",\"value\":\"\"},\"parent_id\":{\"name\":\"parent_id\",\"value\":\"\"},\"sic_code\":{\"name\":\"sic_code\",\"value\":\"\"},\"parent_name\":{\"name\":\"parent_name\",\"value\":\"\"},\"email_opt_out\":{\"name\":\"email_opt_out\",\"value\":\"0\"},\"invalid_email\":{\"name\":\"invalid_email\",\"value\":\"0\"},\"email\":{\"name\":\"email\",\"value\":\"\"},\"campaign_id\":{\"name\":\"campaign_id\",\"value\":\"\"},\"campaign_name\":{\"name\":\"campaign_name\",\"value\":\"\"}}}],\"relationship_list\":[]}",
"headers": [
{
"Name": "Pragma",
"Value": "no-cache",
"Type": 3,
"ContentType": null
},
{
"Name": "Content-Length",
"Value": "6403",
"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:51:10 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=1l112qlpnupq7okfilru3nfft4; 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