public async Task <GetDocumentResponseItem> GetSingleAsync(int documentId) { var document = new GetDocumentResponseItem(); using (var client = _client.GetClient()) { var response = await client.GetAsync($"{ApiControllers.ApiBaseUrl}/{ApiControllers.DocumentPath}/{documentId:F0}"); document.Name = GetFilename(response.Content); document.Data = await response.Content.ReadAsByteArrayAsync(); return(document); } }
public async Task <string> ConnectAsync(string clientId, string clientSecret) { using (var client = _client.GetClient()) { var kvps = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("grant_type", "client_credentials"), new KeyValuePair <string, string>("scope", ""), new KeyValuePair <string, string>("client_id", clientId), new KeyValuePair <string, string>("client_secret", clientSecret), }; var response = await client.PostAsync(ApiControllers.ApiAuthUrl, new FormUrlEncodedContent(kvps)); var authTokenResponse = JsonConvert.DeserializeObject <AuthTokenResponse>(await response.Content.ReadAsStringAsync()); var token = authTokenResponse.AccessToken; _client = new BaseRestClient(token); return(token); } }