我尝试从数据提供者token
获取rest api
。我尝试了以下代码以及Chrome Rest Console
并始终获取401
用户名或密码不正确。我仔细检查了这个并从提供者那里得到了它,我的username:pass
组合是正确的。
也许问题就在这里。 API描述说:/authenticate(POST) username and password need to be send in the request header
在Chrome和.net
我使用basic auth
,问题可能存在吗?或者是否有人有想法,因为我的想法已经不多了。
Sub Main()
Dim client = New RestClient("https://test.com/web/api")
client.Authenticator = New Authenticators.HttpBasicAuthenticator("user.name", "password")
Dim request = New RestRequest("/authenticate", Method.POST)
Dim response As IRestResponse = client.Execute(request)
response = client.Execute(request)
Dim authroizationHeaderFromResponse = response.Headers.FirstOrDefault(Function(h) h.Name = "Authorization")
Console.WriteLine(authroizationHeaderFromResponse.ToString)
If authroizationHeaderFromResponse IsNot Nothing Then
Console.WriteLine(authroizationHeaderFromResponse.Value)
End If
End Sub