C# REST API File Upload

C# REST API File Upload


Hello,

I am using C# and WebClient to add/edit/delete records in Creator and it has been working very well. Please see example below.  This code adds a record, then I have been trying to upload a file to a file upload field.

I am not having any success using WebClient to upload files and have tried a number of combinations based on the Zoho Creator API file upload documentation.  If anyone can point me in the right direction here it will be a big help.

-Wright

var response = Http.Post(" https://creator.zoho.com/api/myzohoapps/xml/ncportal/form/Documents/record/add/", new NameValueCollection() {
       { "authtoken", "****************************" },
       { "scope", "creatorapi" },
       { "crmAccount", "ABC TRUCKING" },
       { "crmAccount_ID", "1696110000000217173" },
       { "Document_Date", "04-24-2017 17:00:00" },
       { "Type", "Contract" },
       { "Tag1", "Transportation"},
       { "Tag2", "Trucking" },});

//*******************************************************
public static class Http
{
public static byte[] Post(string uri, NameValueCollection pairs)
{
    byte[] response = null;
    using (WebClient client = new WebClient())
    {
        response = client.UploadValues(uri, pairs);
    }
    return response;
}
}