Esempio n. 1
0
        public string PostData(Uri url, List <KeyValuePair <string, string> > requestBody, string token, string signingSecret)
        {
            try
            {
                // Create the nonce to be used by the request
                string nonce = GenerateNonce();

                // Create the web request
                HttpWebRequest webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest;

                // Generate a signature
                string signature = SageOneAPIRequestSigner.GenerateSignature("POST", url, requestBody, signingSecret, token, nonce);

                // Set the request headers
                SetHeaders(Method.POST, webRequest, token, signature, nonce);

                // Convert the requestBody into post parameters
                string postParams = ConvertPostParams(requestBody);

                // Send the POST request
                return(SendRequest(webRequest, postParams));
            }
            catch (Exception ex)
            {
                return(ex.Message.ToString());
            }
        }
Esempio n. 2
0
        public string DeleteData(Uri baseurl, string token, string signingSecret)
        {
            // Create the nonce to be used by the request
            string nonce = GenerateNonce();

            // Create the web request
            HttpWebRequest webRequest = System.Net.WebRequest.Create(baseurl) as HttpWebRequest;

            // Generate a signature
            string signature = SageOneAPIRequestSigner.GenerateSignature("DELETE", baseurl, null, signingSecret, token, nonce);

            // Set the request headers
            SetHeaders(Method.DELETE, webRequest, token, signature, nonce);

            // Send the DELETE request
            return(GetRequest(webRequest));
        }