I have a Library wrapper OVH API and i try to call a function for get my consumer key in a ASP.NET MVC project. It works in a Console project application but the method never response in my Controller : the method in the Library
public async Task<CredentialsResponse> RequestCredential(IEnumerable<AccessRule> accessRules, string redirectUrl = null)
{
Ensure.NotNull("accessRules", accessRules);
CredentialsRequest cmd = new CredentialsRequest();
cmd.AccessRules.AddRange(accessRules);
cmd.Redirection = redirectUrl;
if (cmd.AccessRules.Count == 0)
throw new ArgumentException("You must specify at least one accessRule");
return await RawCall<CredentialsResponse>(HttpMethod.Post, "/auth/credential", cmd;
}
and i call in the controller :
public ActionResult Index()
{
Information infosClient = new Information();
OvhApiClient api = new OvhApiClient("", "", OvhInfra.Europe);
CredentialsResponse response = api.RequestCredential(new[]{
new AccessRule{ Method = "GET", Path = "/*"},
new AccessRule{ Method = "PUT", Path = "/*"},
new AccessRule{ Method = "POST", Path = "/*"},
//new AccessRule{ Method = "DELETE", Path = "/*"},
}).Result;
api.ConsumerKey = response.ConsumerKey;
infosClient.ConsumerKey = api.ConsumerKey;
return View(infosClient);
}
I already tried quite a lot of things without success (put the call in a method async for example).
Thanks in advance for your help
Make the controller action async: