Can I translate $ curl commands into ‘Request URL’ commands understood by Swagger in Swagger 'Try It out" mode?
So that I can adapt them to my custom activities or in HTTP Request activity. If so, how?
How to pass ‘login’ and ‘password’ in this VB.NET code as prefix before http://?
curl login:password@localhost:8080/
I have prepared something like this and I have response.
Dim client As HttpClient = New HttpClient()
client.BaseAddress = New Uri(“http://localhost:8080/my-app/”)
client.DefaultRequestHeaders.Accept.Clear()
client.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue(“application/json”))
Dim request As MultipartFormDataContent = New MultipartFormDataContent()
request.Add(New StringContent(“password”), “grant_type”)
request.Add(New StringContent(“robot”), “username”)
request.Add(New StringContent(“robot”), “system”)
response = client.PostAsync(“oauth/token”, request).Result
If response.IsSuccessStatusCode Then
responseContent = response.Content
responseString = responseContent.ReadAsStringAsync.Result
Console.WriteLine(responseString)
Else
Console.WriteLine(("failed: " + response.Content.ReadAsStringAsync.Result))
End If
Therefore, the username and password are thrown into the query (login:password@local...).
Which further serves this Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9[...]
About Postman:
We do not use external tools such as POSTMAN or Chrome add-ons like Talend API Tester in my organization. Access is blocked.
I don’t have how to test it.
I did something like that in VB.NET code: client.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue(“Basic”, “username:password”)
But query fails.
I need to read the documentation.
I have Response StatusCode 200 after passing this query:
Dim client As HttpClient = New HttpClient() client.BaseAddress = New Uri(“http://localhost:8080/my-app/”) client.DefaultRequestHeaders.Accept.Clear() client.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue(“application/json”)) Dim byteArray As Byte() = Encoding.ASCII.GetBytes(“username:password”) client.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue(“Basic”, Convert.ToBase64String(byteArray)) Dim request As MultipartFormDataContent = New MultipartFormDataContent() request.Add(New StringContent(“password”), “grant_type”) request.Add(New StringContent(“robot”), “username”) request.Add(New StringContent(“robot”), “system”) response = client.PostAsync(“oauth/token”, request).Result If response.IsSuccessStatusCode Then responseContent = response.Content responseString = responseContent.ReadAsStringAsync.Result Console.WriteLine(responseString) Else Console.WriteLine(("failed: " + response.Content.ReadAsStringAsync.Result)) End If
which is the equivalent of CURL: curl login:password@localhost:8080/oauth/token -d grant_type=password -d username=robot -d system=robot