2

I'm trying to upload some file to some api, I made a small test with postman, the video of this guy helped me. it works fine!.

Therefore I copied the code from postman, it is possible by clicking the "Code":

enter image description here

Here is the C# code that postman use:

var client = new RestClient("https://te.checkpoint.com/tecloud/api/v1/file/upload");
var request = new RestRequest(Method.POST);
request.AddHeader("Postman-Token", "616790a7-ad25-4687-a749-0b36998b04ac");
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Authorization", "6610F8512D02");
request.AddHeader("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
request.AddParameter("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW", "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"C:\\Users\\Plompy\\Downloads\\rr.pdf\"\r\nContent-Type: application/pdf\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

But when I try from C# console app I recive the response (RestSharp DLL from NuGet is needed)::

<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>

I don't care about that you see my autorithetion key. It's a free 30 days trial account.

Plompy
  • 359
  • 3
  • 11
  • do you use the same code on console? you can use https://www.telerik.com/fiddler to see traffic and know what's going on. – andres descalzo Aug 29 '18 at 19:01
  • If I try instead of `C:\\Users\\Plompy\\Downloads\\rr.pdf` I write: `somefileName` I get full response from the server, but in the response I see the he gives md5 of empty string, i.e the server didn't recieved the file. – Plompy Aug 29 '18 at 19:08

0 Answers0