Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. request.AddParameter("text/plain", body, ParameterType.RequestBody);
  2.  
  3. public static void UploadFile(string bearer)
  4. {
  5. var client = new RestClient("...");
  6. var request = new RestRequest(Method.POST);
  7. request.AddHeader("Authorization", "Bearer " + bearer);
  8. request.AddHeader("cache-control", "no-cache");
  9.  
  10. var imageLenngth = new FileInfo(@"...").Length;
  11.  
  12. request.AddHeader("Content-Type", "image/jpeg");
  13. request.AddHeader("Content-Length", imageLenngth.ToString());
  14.  
  15. byte[] body = File.ReadAllBytes(@"...");
  16.  
  17. request.AddParameter("text/plain", body, ParameterType.RequestBody);
  18.  
  19. IRestResponse response = client.Execute(request);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement