public void ComposeGetRequest() { RequestOptionsEncrypted options = new RequestOptionsEncrypted(config, HttpMethod.Get, "/my/path"); var reqMessage = options.ComposeRequestMessage(); Assert.Equal(HttpMethod.Get, reqMessage.Method); Assert.Equal("/base/url/my/path", reqMessage.RequestUri.ToString()); }
public async void ComposePostRequest() { RequestOptionsEncrypted options = new RequestOptionsEncrypted(config, HttpMethod.Post, "/my/path", "['prop1': 12, 'prop2': 'abc']"); var reqMessage = options.ComposeRequestMessage(); Assert.Equal(HttpMethod.Post, reqMessage.Method); Assert.Equal("/base/url/my/path", reqMessage.RequestUri.ToString()); string content = await reqMessage.Content.ReadAsStringAsync(); Assert.Equal("['prop1': 12, 'prop2': 'abc']", content); }
public async Task <ApiResponse <T> > SendRequest <T>(HttpMethod method, string path, string payload = null) { RequestOptionsEncrypted requestOptions = new RequestOptionsEncrypted( configuration, method, path, payload); string content = await _requester.SendAsync(requestOptions); return(JsonConvert.DeserializeObject <ApiResponse <T> >(content)); }