Guest User

Untitled

a guest
Sep 14th, 2018
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. Sub Main()
  2.  
  3.  
  4. client = New DataExtractor("https://pagename.com/web/service", "MyUsername", "MyPassword")
  5. Try
  6. token = client.getToken
  7. Catch ex As Exception
  8. End Try
  9. End Main
  10.  
  11. Public Class DataExtractor
  12. Private _baseURI As String
  13. Private _passWord As String
  14. Private _userName As String
  15.  
  16. Sub New(ByVal baseUri As String, ByVal userName As String, ByVal password As String)
  17. _baseURI = baseUri
  18. _userName = userName
  19. _passWord = password
  20. End Sub
  21.  
  22.  
  23. Public Function getToken() As String
  24. Dim client = New RestClient(_baseURI)
  25. Dim request = New RestRequest("/auth/token", Method.POST)
  26.  
  27. request.AddHeader("username", _userName)
  28. request.AddHeader("password", _passWord)
  29. request.AddHeader("enviroment", "myEnv")
  30. request.AddHeader("grant_type", "password")
  31. request.AddHeader("Content-Type", "application/x-www-form-urlencoded")
  32.  
  33. Dim response As IRestResponse = client.Execute(request)
  34. response = client.Execute(request)
  35. Return response.Content
  36.  
  37. End Function
  38.  
  39. HTTP Status 404 ? Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/8.5.33</h3></body></html>
  40.  
  41. "POST /web/service/auth/token HTTP/1.1" 302 - "-" "RestSharp/105.2.3.0"
  42. "GET /web/service/auth/token HTTP/1.1" 404 1043 "-" "RestSharp/105.2.3.0"
Add Comment
Please, Sign In to add comment