Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. public string GetToken()
  2. {
  3. try
  4. {
  5. var smartStoreUrl = "http://" + Configuration.Configuration.Config.RsAppServer + "/RS.WebClient.Api/api/account/login";
  6. var client = new RestClient(smartStoreUrl);
  7. var request = new RestRequest(Method.POST) { RequestFormat = DataFormat.Json };
  8. request.AddBody(new { UserName = Configuration.Configuration.Config.RsAppServerUsername, Password = Configuration.Configuration.Config.RsAppServerPassword });
  9. var response = client.Execute(request);
  10.  
  11. if (response.StatusCode == HttpStatusCode.OK)
  12. {
  13. var responseObject = JsonConvert.DeserializeObject<LoginObject>(response.Content);
  14. return responseObject.token;
  15. }
  16. return null;
  17. }
  18. catch (Exception)
  19. {
  20. return null;
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement