Beispiel #1
0
        public static async Task <TResponseModel> ExecuteWithModelAsync <TResponseModel>(this HttpClient client, IOvhApiCredentials credential, HttpMethod method, string urlPart, Dictionary <string, object> formdata = null, object model = null)
        {
            try
            {
                HttpRequestMessage req = new HttpRequestMessage(method, urlPart);
                if (model != null)
                {
                    req.Content = OvhApiTools.JsonContent(model);
                }
                await OvhApiTools.SignRequestAsync(req, credential);

                HttpResponseMessage resp = await client.SendAsync(req);

                OvhApiTools.Validate(resp);
                TResponseModel retour = await OvhApiTools.ReadWithModelAsync <TResponseModel>(resp);

                return(retour);
            }
            catch (Exception ex)
            {
                throw;
            }
        }