0

I'm trying to make a post request which has three parameters out of with two are string but the third one is a file that needs to be uploaded. I tried the following code but doesn't work.. It will provide some overview.

using System;

namespace WorkDrive
{
    class Program
    {
        static void Main(string[] args)
        {

            string AuthToken = "xxxxxxxxxxxxxxxxxxxxxx";
            string url = string.Format("https://apidocs.zoho.com/files/v1/upload?authtoken=" + AuthToken + "&scope=docsapi"");
            string FolderID = "xxxxxxxxxxxxxx";
            string fileName = "a.xls";
            var client = new RestClient(url);
            var request = new RestRequest();
            request.AddParameter("fid", FolderID);
            request.AddParameter("filename", fileName);
            request.AddFile("content", "Path to File\\a.xls");
            var response = client.Post(request);
            var content = response.Content; // raw content as string
            Console.WriteLine(content);
            Console.ReadLine();


        }
    }
}
Nawaf Momin
  • 127
  • 1
  • 1
  • 9
  • What is the target .NET framework? If 4.0 or higher, you should use **HttpClient** class, some example [here](https://stackoverflow.com/questions/1131425/send-a-file-via-http-post-with-c-sharp) – Bruno Martins Feb 20 '20 at 08:53
  • what are these parameter string paramString, Stream paramFileStream, byte [] paramFileBytes? – Nawaf Momin Feb 20 '20 at 10:22

0 Answers0