'What's the .NET equivalent to sending a file using postman
I have a working postman call in which I send a json file.
The json file is sent using form-data and I import the file using the file dropdown in the formdata parameters

Now I try to implement the same call in .NET using the HTTPClient and StreamContent classes:
ms.Position = 0;
StreamContent sc = new StreamContent(ms);
formdataContent.Add(sc, "data");
When I now send the formdataContent to the interface, the interface complains that the JSON is in textformat rather than file format.
Edit: Had the same results using ByteArrayContent
Solution 1:[1]
var client = new RestClient("https://localhost:5001/api/v1/user/uploadphoto");
// client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddFile("image", "9TbdT39_c/test.csv");
request.AddParameter("name", "ram");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
