locked
Hi! I got a problem make the curl command equivalent to my C# RRS feed

  • Question

  • User892177034 posted
    $ curl
    -X POST
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
    -F "recipients[0][name]=John"
    -F "recipients[0][email]=john.doe@gmail.com"
    -F "files[0]=@/path/to/the/pdf/document.pdf"
    https://api.sandbox.signaturit.com/v3/signatures.json

    try to do it like this

    using System;
    using System.IO;
    using System.Net;
    using System.Text;
    using System.Web;
    
    public class Program
    {
        public static void Main()
        {
            string response = SendSignatureRequest(
    	    	"ZDM4NzU1YTVmNmFhNGMwMGQ3MTdiOTBhNmNiZDQzOTlkYjg4OTk0MTg5MGM3OGFlZjk1OWM1ZDg1NTQxYzBjYQ",
                "Mario",
                "rikimay535@gmail.com",
    			//"http://www.analysis.im/uploads/seminar/pdf-sample.pdf"
    			"@c://Mariete.pdf"
            );
            Console.WriteLine(response);
        }
    
        public static string SendSignatureRequest(string apiKey, string name, string email, string file)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.sandbox.signaturit.com/v3/signatures.json");
            request.Method = "POST";
    		
            string authorization = apiKey;
            request.Headers.Add("Authorization", "Bearer " + authorization);
    		
          
    
    		var postData = "recipients[0][name]=" + name;
                postData += "&recipients[0][email]=" + email;
    		    postData += "&files[0]=" + file;
    		    
          
            var data = Encoding.ASCII.GetBytes(postData);
    		
            request.ContentType = "application/json";
            request.ContentLength = data.Length;
            
            using (var stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
    			
            }
    
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            return new StreamReader(response.GetResponseStream()).ReadToEnd();
        }
    }

    Monday, May 23, 2016 9:27 AM

All replies

  • User303363814 posted

    Do you have a question?

    Monday, May 23, 2016 8:49 PM