<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>rest JavaScript API Module</title><link>https://community.telligent.com/community/11/w/api-documentation/65559/rest-javascript-api-module</link><description /><dc:language>en-US</dc:language><generator>14.0.0.586 14</generator><item><title>rest JavaScript API Module</title><link>https://community.telligent.com/community/11/w/api-documentation/65559/rest-javascript-api-module</link><pubDate>Thu, 13 Jun 2019 19:55:10 GMT</pubDate><guid isPermaLink="false">8cef9e60-099e-4776-8b56-2c0bcd37064e</guid><dc:creator>Ben Tiedt</dc:creator><comments>https://community.telligent.com/community/11/w/api-documentation/65559/rest-javascript-api-module#comments</comments><description>Current Revision posted to API Documentation by Ben Tiedt on 06/13/2019 19:55:10&lt;br /&gt;
&lt;hr class="generated-documentation-start" style="border-width:0;" /&gt;
&lt;h3&gt;&lt;a id="jQuery_telligent_evolution_REST_helpers" name="jQuery_telligent_evolution_REST_helpers"&gt;&lt;/a&gt;jQuery.telligent.evolution REST helpers&lt;/h3&gt;
&lt;p&gt;This module exposes helper methods to assist with performing ajax requests against the REST API. They are essentially thin wrappers over &lt;a href="http://api.jquery.com/jQuery.ajax/"&gt;jQuery.ajax()&lt;/a&gt;, and all options supported by jQuery.ajax() are supported by these wrappers. However, using these wrappers provides the following benefits:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Auth Tokens are automatically pre-set on the requests&amp;#39; headers. Security &amp;quot;just works&amp;quot;&lt;/li&gt;
&lt;li&gt;The proper Rest-Method verb overload header is added when it&amp;#39;s a PUT or DELETE&lt;/li&gt;
&lt;li&gt;Items in the data option are automatically interpolated into the parameterized Endpoint URL as demonstrated below.&lt;/li&gt;
&lt;li&gt;REST api endpoints&amp;#39; parameters are automatically uri-encoded&lt;/li&gt;
&lt;li&gt;Multiple REST requests can be batched into parallel or sequential unified requests&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;&lt;a id="Methods" name="Methods"&gt;&lt;/a&gt;Methods&lt;/h4&gt;
&lt;h4&gt;&lt;a id="get" name="get"&gt;&lt;/a&gt;get&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;$.telligent.evolution.get(options)
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;&lt;a id="post" name="post"&gt;&lt;/a&gt;post&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;$.telligent.evolution.post(options)
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;&lt;a id="put" name="put"&gt;&lt;/a&gt;put&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;$.telligent.evolution.put(options)
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;&lt;a id="del" name="del"&gt;&lt;/a&gt;del&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;$.telligent.evolution.del(options)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Options is an optional object which supports all the same parameters defined by &lt;a href="http://api.jquery.com/jQuery.ajax/"&gt;jQuery.ajax()&lt;/a&gt;. However, there is no need to set auth tokens or Rest-Method overload headers via &lt;code&gt;beforeSend()&lt;/code&gt;. Additionally, error handling is provided out of the box via display of a notification containing the error. This can be overridden with the standard error handler parameter.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Additional Supported Options&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;batch&lt;/code&gt;: (number) When provided, defers execution of the request until the associated batch is run&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;&lt;a id="batch" name="batch"&gt;&lt;/a&gt;batch&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;$.telligent.evolution.batch(function() {
    // ordinary REST requests
    // $.telligent.evolution.post({...})
    // $.telligent.evolution.get({...})
    // $.telligent.evolution.put({...})
}, options);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;High-level syntax wrapper which runs all wrapped REST requests in a single batched HTTP request. Each REST request still supports individual success/error callbacks as well as individual promise callbacks, though these callbacks are not executd until the batch completes. It is &lt;em&gt;not&lt;/em&gt; necessary to pass an explicit batch id to REST requests performed within a call to &lt;code&gt;batch()&lt;/code&gt;. Bathches created using this method cannot be nested. Returns a promise which resolves when the entire batch completes.&lt;/p&gt;
&lt;p&gt;Options is an optional object supporting:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;sequential&lt;/code&gt;: (bool) When true, performs each batched request in order on the server. When false, runs them in parallel on the server. A sequential batch that contains a failed request will halt all subsequent requests in the batch and reject the entire batch promise. Any successful sub-requests are still resolved. Parallel requests that contain one or more failed requests still resolve the entire batch and do not halt other sub requests.
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;default:&lt;/em&gt; false&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;beforeSend&lt;/code&gt;: (function) function which accepts an XmlHttpRequest to perform an action before the parent batch&amp;#39;s ajax request is performed. Individual &lt;code&gt;beforeSend&lt;/code&gt; callbacks on batch sub-requests are not supported.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;&lt;a id="batch_create" name="batch_create"&gt;&lt;/a&gt;batch.create&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;var batchId = $.telligent.evolution.batch.create();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Lower-level method for specifically creating a batch context. Calls to &lt;code&gt;get()&lt;/code&gt;, &lt;code&gt;post()&lt;/code&gt;, &lt;code&gt;put()&lt;/code&gt;, and &lt;code&gt;del()&lt;/code&gt; support a &lt;code&gt;batch&lt;/code&gt; parameter which defers their execution until the associated batch is run. Batch contexts expire after 60 seconds of not being executed.&lt;/p&gt;
&lt;p&gt;It is usually simpler to use the higher-level &lt;code&gt;$.telligent.evolution.batch()&lt;/code&gt; method instead, except in cases where it isn&amp;#39;t feasible to wrap all REST requests in a single function scope.&lt;/p&gt;
&lt;h4&gt;&lt;a id="batch_process" name="batch_process"&gt;&lt;/a&gt;batch.process&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;$.telligent.evolution.batch.process(batchId, options);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Lower-level method which runs a batched REST request with all REST requests associated with that batch ID. Returns a promise which resolves when the entire batch completes.&lt;/p&gt;
&lt;p&gt;Options is an optional object supporting:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;sequential&lt;/code&gt;: (bool) When true, performs each batched request in order on the server. When false, runs them in parallel on the server. A sequential batch that contains a failed request will halt all subsequent requests in the batch and reject the entire batch promise. Any successful sub-requests are still resolved. Parallel requests that contain one or more failed requests still resolve the entire batch and do not halt other sub requests.
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;default:&lt;/em&gt; false&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;beforeSend&lt;/code&gt;: (function) function which accepts an XmlHttpRequest to perform an action before the parent batch&amp;#39;s ajax request is performed. Individual &lt;code&gt;beforeSend&lt;/code&gt; callbacks on batch sub-requests are not supported.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is usually simpler to use the higher-level &lt;code&gt;$.telligent.evolution.batch()&lt;/code&gt; method instead, except in cases where it isn&amp;#39;t feasible to wrap all REST requests in a single function scope.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Examples" name="Examples"&gt;&lt;/a&gt;Examples&lt;/h3&gt;
&lt;h4&gt;&lt;a id="Deleting_a_user_from_a_group" name="Deleting_a_user_from_a_group"&gt;&lt;/a&gt;Deleting a user from a group.&lt;/h4&gt;
&lt;p&gt;Note that the &lt;code&gt;{GroupId}&lt;/code&gt; and &lt;code&gt;{UserId}&lt;/code&gt; parameters in the URL are left parameterized, and items in data will resolve to the URL before it is requested.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;jQuery.telligent.evolution.del({
    url: $.telligent.evolution.site.getBaseUrl() + &amp;#39;/api.ashx/v2/groups/{GroupId}/members/users/{UserId}.json&amp;#39;,
    data: {
        GroupId: 5,
        UserId: 2107
    },
    success: function(response) { console.log(response); }
});
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;&lt;a id="Add_a_message_to_an_existing_conversation" name="Add_a_message_to_an_existing_conversation"&gt;&lt;/a&gt;Add a message to an existing conversation&lt;/h4&gt;
&lt;p&gt;Note that in this case, Id gets interpolated into the raw API endpoint as &lt;code&gt;/api.ashx/v2/conversations/50.json&lt;/code&gt;, but &lt;code&gt;Subject&lt;/code&gt; and &lt;code&gt;Body&lt;/code&gt; are still passed as post parameters, and &lt;code&gt;Id&lt;/code&gt; is not&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;jQuery.telligent.evolution.post({
    url: $.telligent.evolution.site.getBaseUrl() + &amp;#39;/api.ashx/v2/conversations/{Id}.json&amp;#39;,
    data: {
        Id: 50,
        Subject: &amp;quot;New Mesage Subject&amp;quot;,
        Body: &amp;quot;New Message Body&amp;quot;
    },
    success: function(response) { console.log(response); }
});
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;&lt;a id="Request_Conversations" name="Request_Conversations"&gt;&lt;/a&gt;Request Conversations&lt;/h4&gt;
&lt;p&gt;This is a more traditional scenario, where &lt;code&gt;PageSize&lt;/code&gt; and &lt;code&gt;PageIndex&lt;/code&gt; are passed as query string parameters to the URL, which needs no interpolation.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;jQuery.telligent.evolution.get({
    url: $.telligent.evolution.site.getBaseUrl() + &amp;#39;/api.ashx/v2/conversations.json&amp;#39;,
    data: {
        PageSize: 10,
        PageIndex: 3
    },
    success: function(response) { console.log(response); }
});
&lt;/code&gt;&lt;/pre&gt;
&lt;hr class="generated-documentation-end" style="border-width:0;" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item></channel></rss>