CSLibrary/Webhook.cs
/// <summary>
/// Create Webhook that will be Triggered when the Specified Event Takes Place
/// </summary>
/// <param name="AccessToken"></param>
/// <param name="EventType">document.create, document.update, document.delete, invite.create, invite.update</param>
/// <param name="CallbackUrl">The URL called when the even is triggered.</param>
/// <param name="ResultFormat">JSON, XML</param>
/// <returns>ID, Created, Updated</returns>
Create Webhook that will be Triggered when the Specified Event Takes Place
Create Webhook that will be Triggered when the Specified Event Takes Place
public static dynamic Create(string AccessToken, string EventType, string CallbackUrl, string ResultFormat = "JSON")
        {
            var client = new RestClient();
            client.BaseUrl = new Uri(Config.ApiHost);
            var request = new RestRequest("/event_subscription", Method.POST)
                .AddHeader("Accept", "application/json")
                .AddHeader("Authorization", "Bearer " + AccessToken);
            request.RequestFormat = DataFormat.Json;
            dynamic jsonObj = new ExpandoObject();
            jsonObj.@event = EventType;
            jsonObj.callback_url = CallbackUrl;
            request.AddBody(jsonObj);
            var response = client.Execute(request);
            dynamic results = "";
            if (response.StatusCode == HttpStatusCode.OK)
            {
                results = response.Content;
            }
            else
            {
                Console.WriteLine(response.Content.ToString());
                results = response.Content.ToString();
            }
            if (ResultFormat == "JSON")
            {
                results = JsonConvert.DeserializeObject(results);
            }
            else if (ResultFormat == "XML")
            {
                results = (XmlDocument)JsonConvert.DeserializeXmlNode(results, "root");
            }
            return results;
        }
public static dynamic Create ( string AccessToken , string EventType , string CallbackUrl , string ResultFormat = " " ) { var client = new RestClient ( ) ; client . BaseUrl = new Uri ( Config . ApiHost ) ; var request = new RestRequest ( " " , Method . POST ) . AddHeader ( " " , " " ) . AddHeader ( " " , " " + AccessToken ) ; request . RequestFormat = DataFormat . Json ; dynamic jsonObj = new ExpandoObject ( ) ; jsonObj . @event = EventType ; jsonObj . callback_url = CallbackUrl ; request . AddBody ( jsonObj ) ; var response = client . Execute ( request ) ; dynamic results = " " ; if ( response . StatusCode == HttpStatusCode . OK ) { results = response . Content ; } else { Console . WriteLine ( response . Content . ToString ( ) ) ; results = response . Content . ToString ( ) ; } if ( ResultFormat == " " ) { results = JsonConvert . DeserializeObject ( results ) ; } else if ( ResultFormat == " " ) { results = ( XmlDocument ) JsonConvert . DeserializeXmlNode ( results , " " ) ; } return results ; }
Create Webhook that will be Triggered when the Specified Event Takes Place
Create Webhook that will be Triggered when the Specified Event Takes Place
ID, Created, Updated
ID Created Updated
AccessToken
string
None
EventType
string
document.create, document.update, document.delete, invite.create, invite.update
document . create document . update document . delete invite . create invite . update
CallbackUrl
string
The URL called when the even is triggered.
The URL called when the even is triggered .
ResultFormat
string
None