<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Create Module</title><link>https://sourceforge.net/p/sugarrestsharp/wiki/Create%2520Module/</link><description>Recent changes to Create Module</description><atom:link href="https://sourceforge.net/p/sugarrestsharp/wiki/Create%20Module/feed" rel="self"/><language>en</language><lastBuildDate>Sun, 18 Dec 2016 17:24:07 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/sugarrestsharp/wiki/Create%20Module/feed" rel="self" type="application/rss+xml"/><item><title>Create Module modified by Kola Oyewumi</title><link>https://sourceforge.net/p/sugarrestsharp/wiki/Create%2520Module/</link><description>&lt;div class="markdown_content"&gt;&lt;h2 id="basic-usage"&gt;Basic Usage&lt;/h2&gt;
&lt;p&gt;This sample usage shows how to create a "Bugs" module entity data. For more request options make changes to the &lt;a class="" href="../Request%20Options"&gt;Options parameter&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This implements the &lt;strong&gt;&lt;em&gt;set_entry&lt;/em&gt;&lt;/strong&gt; SugarCRM REST API method.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="nt"&gt;using&lt;/span&gt; &lt;span class="nt"&gt;SugarRestSharp&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nt"&gt;string&lt;/span&gt; &lt;span class="nt"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"http://191.101.224.189/sugar/service/v4_1/rest.php"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;string&lt;/span&gt; &lt;span class="nt"&gt;username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"will"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;string&lt;/span&gt; &lt;span class="nt"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"will"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nt"&gt;string&lt;/span&gt; &lt;span class="nt"&gt;moduleName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Bugs"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nt"&gt;var&lt;/span&gt; &lt;span class="nt"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;new&lt;/span&gt; &lt;span class="nt"&gt;SugarRestClient&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;url&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;username&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;password&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nt"&gt;var&lt;/span&gt; &lt;span class="nt"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;new&lt;/span&gt; &lt;span class="nt"&gt;SugarRestRequest&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;moduleName&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;RequestType&lt;/span&gt;&lt;span class="nc"&gt;.Create&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

&lt;span class="nt"&gt;Bug&lt;/span&gt; &lt;span class="nt"&gt;bugToCreate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;new&lt;/span&gt; &lt;span class="nt"&gt;Bug&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="nt"&gt;bugToCreate&lt;/span&gt;&lt;span class="nc"&gt;.Name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"System crashed while running count query"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;bugToCreate&lt;/span&gt;&lt;span class="nc"&gt;.Description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"New Oracle application server commissioning."&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;bugToCreate&lt;/span&gt;&lt;span class="nc"&gt;.Status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"New"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nt"&gt;request&lt;/span&gt;&lt;span class="nc"&gt;.Parameter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;bugToCreate&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;Select&lt;/span&gt; &lt;span class="nt"&gt;fields&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="nt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;selectFields&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;new&lt;/span&gt; &lt;span class="nt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;();&lt;/span&gt;
&lt;span class="nt"&gt;selectFields&lt;/span&gt;&lt;span class="nc"&gt;.Add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;nameof&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;Bug&lt;/span&gt;&lt;span class="nc"&gt;.Name&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
&lt;span class="nt"&gt;selectFields&lt;/span&gt;&lt;span class="nc"&gt;.Add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;nameof&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;Bug&lt;/span&gt;&lt;span class="nc"&gt;.Description&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
&lt;span class="nt"&gt;selectFields&lt;/span&gt;&lt;span class="nc"&gt;.Add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;nameof&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;Bug&lt;/span&gt;&lt;span class="nc"&gt;.Status&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;

&lt;span class="nt"&gt;request&lt;/span&gt;&lt;span class="nc"&gt;.Options.SelectFields&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;selectFields&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nt"&gt;SugarRestResponse&lt;/span&gt; &lt;span class="nt"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;client&lt;/span&gt;&lt;span class="nc"&gt;.Execute&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;request&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h3 id="response-data"&gt;Response (Data)&lt;/h3&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;string createdBugId = (string)response.Data;
&lt;/pre&gt;&lt;/div&gt;


&lt;h3 id="response-jdata"&gt;Response (JData)&lt;/h3&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;49a8ff9f-e1d4-2135-c132-5855b99916a6
&lt;/pre&gt;&lt;/div&gt;


&lt;h3 id="response-jsonrawrequest"&gt;Response (JsonRawRequest)&lt;/h3&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;{
  "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"
}
&lt;/pre&gt;&lt;/div&gt;


&lt;h3 id="response-jsonrawresponse"&gt;Response (JsonRawResponse)&lt;/h3&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;{
  "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
}
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kola Oyewumi</dc:creator><pubDate>Sun, 18 Dec 2016 17:24:07 -0000</pubDate><guid>https://sourceforge.net5377afb8730d915ceafbcc799141ce1530c86807</guid></item></channel></rss>