I need to get a token for a REST call. The token should be in a JSON result.
https://github.com/bic-boxtech/BIC-BoxTech-API-Samples/wiki/Authentication
Here is the way I tried it:
private async void GetBicDataAsync()
{
HttpClient _bicAothClient;
_bicAothClient = new HttpClient();
_bicAothClient.DefaultRequestHeaders.Add("Authorization", "Basic YmljYXBwOmJpY3NlY3JldGFwcA==");
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("grant_type", "password"),
new KeyValuePair<string, string>("username", Constants.BicAothUser),
new KeyValuePair<string, string>("password", Constants.BicAothPassword)
});
var result = await _bicAothClient.PostAsync(Constants.BicAothEndpoint, content);
}
But I get an 400:
{"statusCode":400,"status":400,"code":400,"message":"Invalid request: method must be POST","name":"invalid_request"}
What did I wrong. I thing it's a small stupid fail. Can someone help me please.
if you get the content as a string you can use this code to get every values from the endpoint separated:
You get the full list of objects in the Swagger example.
I contacted the provider and see... the wiki was wrong. Both URLs I needed were incorrect. Now here is a code to get everything you want: