Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using RestSharp;
- using RestSharp.Authenticators;
- using System.IO;
- namespace TestService
- {
- class Program
- {
- static private string xml = "";
- static private string url = @"https://agreement.plus/api/test/agreement/check";
- static private string username = "test";
- static private string password = "ili2i5li_l9ili1i";
- static void Main(string[] args)
- {
- string path = @"C:\TEST";
- foreach (string file in Directory.EnumerateFiles(path))
- {
- xml = File.ReadAllText(file);
- }
- var request = new RestRequest
- {
- Method = Method.POST,
- RequestFormat = DataFormat.Xml,
- };
- RestClient client = new RestClient(url)
- {
- Authenticator = new HttpBasicAuthenticator(username, password)
- };
- request.AddHeader("Content-Type", "application/xml; charset=utf-8");
- request.AddParameter("application/xml", xml, ParameterType.RequestBody);
- request.Timeout = 60000;
- var response = client.Execute(request);
- string content = response.Content;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement