Advertisement
Guest User

Untitled

a guest
Feb 25th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. using RestSharp;
  2. using RestSharp.Authenticators;
  3. using System.IO;
  4.  
  5. namespace TestService
  6. {
  7. class Program
  8. {
  9. static private string xml = "";
  10. static private string url = @"https://agreement.plus/api/test/agreement/check";
  11. static private string username = "test";
  12. static private string password = "ili2i5li_l9ili1i";
  13. static void Main(string[] args)
  14. {
  15. string path = @"C:\TEST";
  16. foreach (string file in Directory.EnumerateFiles(path))
  17. {
  18. xml = File.ReadAllText(file);
  19. }
  20.  
  21.  
  22.  
  23. var request = new RestRequest
  24. {
  25. Method = Method.POST,
  26. RequestFormat = DataFormat.Xml,
  27. };
  28.  
  29.  
  30.  
  31. RestClient client = new RestClient(url)
  32. {
  33. Authenticator = new HttpBasicAuthenticator(username, password)
  34. };
  35.  
  36.  
  37. request.AddHeader("Content-Type", "application/xml; charset=utf-8");
  38. request.AddParameter("application/xml", xml, ParameterType.RequestBody);
  39. request.Timeout = 60000;
  40.  
  41.  
  42.  
  43. var response = client.Execute(request);
  44. string content = response.Content;
  45.  
  46. }
  47.  
  48.  
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement