Example #1
0
        public static string SendPostRequest(string postURL, Dictionary <string, object> postParameters)
        {
            var req = FormUpload.MultipartFormDataPost(postURL, "", postParameters);

            Stream       st             = req.GetResponseStream();
            StreamReader responseStream = new StreamReader(st, Encoding.UTF8);
            string       strJsonData    = responseStream.ReadToEnd();

            return(strJsonData);
        }
Example #2
0
        public static string SendPostRequestWithBody(string postURL,
                                                     Dictionary <string, object> postParameters)//multipart/form-data
        {
            try
            {
                string formDataBoundary = String.Format("----------{0:N}", Guid.NewGuid());
                string contentType      = "multipart/form-data; boundary=" + formDataBoundary;

                byte[] formData = FormUpload.GetMultipartFormData(postParameters, formDataBoundary);

                HttpWebResponse response = FormUpload.MultipartFormDataPost(postURL, "", postParameters);

                string strJsonData = new StreamReader(response.GetResponseStream(), Encoding.UTF8).ReadToEnd();

                return(strJsonData);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }