Guest User

Untitled

a guest
Jan 16th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. var client = new RestClient("localhost:5000/api/login");
  2. var request = new RestRequest(Method.POST);
  3. request.AddJsonBody("User Model that I created");
  4. request.AddHeader("Accept", "application/json");
  5. request.RequestFormat = DataFormat.Json;
  6. IRestResponse response = client.Execute(request);
  7. //Store the response token in session
  8.  
  9. //Subsequent calls
  10. var client = new RestClient("localhost:5000/api/values");
  11. var request = new RestRequest(Method.GET);
  12. request.AddHeader("authorization", "Bearer TOKEN_FROM_SESSION_STORAGE");
  13. request.AddHeader("content-type", "application/json");
  14. IRestResponse response = client.Execute(request);
Add Comment
Please, Sign In to add comment