This sample usage shows how to create a "Bugs" module entity data. For more request options make changes to the Options parameter.
This implements the set_entry SugarCRM REST API method.
using SugarRestSharp; string url = "http://191.101.224.189/sugar/service/v4_1/rest.php"; string username = "will"; string password = "will"; string moduleName = "Bugs"; var client = new SugarRestClient(url, username, password); var request = new SugarRestRequest(moduleName, RequestType.Create); Bug bugToCreate = new Bug(); bugToCreate.Name = "System crashed while running count query"; bugToCreate.Description = "New Oracle application server commissioning."; bugToCreate.Status = "New"; request.Parameter = bugToCreate; // Select fields. List<string> selectFields = new List<string>(); selectFields.Add(nameof(Bug.Name)); selectFields.Add(nameof(Bug.Description)); selectFields.Add(nameof(Bug.Status)); request.Options.SelectFields = selectFields; SugarRestResponse response = client.Execute(request);
string createdBugId = (string)response.Data;
49a8ff9f-e1d4-2135-c132-5855b99916a6
{ "resource": "", "parameters": [ { "name": "method", "value": "set_entry", "type": "GetOrPost" }, { "name": "input_type", "value": "json", "type": "GetOrPost" }, { "name": "response_type", "value": "json", "type": "GetOrPost" }, { "name": "rest_data", "value": "{\"session\":\"38na12v9o725e27rh782qfgbl7\",\"module_name\":\"Bugs\",\"name_value_list\":{\"name\":{\"name\":\"name\",\"value\":\"System crashed while running count query\"},\"description\":{\"name\":\"description\",\"value\":\"New Oracle application server commissioning.\"},\"status\":{\"name\":\"status\",\"value\":\"New\"}}}", "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": "{\"id\":\"49a8ff9f-e1d4-2135-c132-5855b99916a6\",\"entry_list\":{\"name\":{\"name\":\"name\",\"value\":\"System crashed while running count query\"},\"description\":{\"name\":\"description\",\"value\":\"New Oracle application server commissioning.\"},\"status\":{\"name\":\"status\",\"value\":\"New\"}}}", "headers": [ { "Name": "Pragma", "Value": "no-cache", "Type": 3, "ContentType": null }, { "Name": "Content-Length", "Value": "267", "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": "Sat, 17 Dec 2016 22:16:47 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=38na12v9o725e27rh782qfgbl7; 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 }
Wiki: Home
Wiki: Request Options
Wiki: Welcome to SugarRestSharp wiki!
Wiki: _Sidebar