Post file binary does not work

Options

As Im writing a post method to connect with PipeDrive api I encountered a convertion problem(or the lack of convertion).

As documentation says the file should be send as a binary file.This is my code in c# to convert the file.

Byte[] bytes = System.IO.File.ReadAllBytes(filePath);
String file = Convert.ToBase64String(bytes);

Any idea how to send the file properly so it can be downloaded and working?

This code does not work, result says the file is empty:

body.Add(new StreamContent(File.OpenRead(filePath)), "file", fileName);

Tagged:

Answers