Fileupload through API in c#

Fileupload through API in c#

Hi

Using the below code for uplaoding a file through API in c#. Getting the error : Invalid URL!!.
Have given the correct url mentioned in zoho api ( https://www.zoho.com/docs/zoho-docs-api.html#upload).
Please let me know what correction is required to upload a file successfully.


public async Task<string> UploadFile()
        {
            var retunVal = "";
            using (HttpClient httpClient = new HttpClient())
            {
                using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, @" https://apidocs.zoho.com/files/v1/upload?authtoken=ed4eef708508749dcd63f38b730abcde&scope=docsapi"))
                {
                    request.Properties.Add("filename", "Untitled.jpg");
                    using (FileStream fstream = File.Open(@"C:\Users\jharikrishna\Desktop\Untitled.jpg", FileMode.Open))
                    {
                        request.Properties.Add("content", fstream);

                        retunVal = await (await httpClient.SendAsync(request)).Content.ReadAsStringAsync();
                    }
                }
            }

            return retunVal;
        }


Note:  Have also tried tried passing bytearray instead of stream for the content parameter value. The result is the same.