Hi finally I am to to upload bytes to hubspot in C#
Working code
var file = File.ReadAllBytes("C:\\Users\\abhimanyu.kumar\\Downloads\\1.png"); var request = new RestRequest(Method.POST); var client = new RestClient("http://api.hubapi.com/files/v3/files?hapikey=key");
Hi finally I am to to upload bytes to hubspot in C#
Working code
var file = File.ReadAllBytes("C:\\Users\\abhimanyu.kumar\\Downloads\\1.png"); var request = new RestRequest(Method.POST); var client = new RestClient("http://api.hubapi.com/files/v3/files?hapikey=key");
I think the issue is that the overall request should use the content type of multipart/form-data. Then the file itself should have applicaiton/octet-stream.
Maybe the file header is wrong but if you found a way to do it it's a good new. C# is not my main programming lang, i use to learn at university but now i'm most of the time doing nodeJs and php
Hi @quentin_lamamy@dennisedson this is working code but intead of file path "C:\\Users\\abhimanyu.kumar\\Downloads\\1.png" I wasnt to send bytes like var file = new ByteArrayContent(File.ReadAllBytes("C:\\Users\\abhimanyu.kumar\\Downloads\\1.png")); file.Headers.Add("Content-Type", "application/octet-stream"); And I am trying it and response I am getting is unspupported type
What is supported type for file?
Working Code: var options1 = new { access = "PUBLIC_INDEXABLE" };
var properties1 = JsonConvert.SerializeObject(options1); var request1 = new RestRequest(Method.POST); var client = new RestClient("http://api.hubapi.com/files/v3/files?hapikey=demo"); request1.AddFile("file", "C:\\Users\\abhimanyu.kumar\\Downloads\\1.png"); request1.AddParameter("folderId", "381726034078"); request1.AddParameter("options", properties1); IRestResponse response1 = client.Execute(request1);