public void TestGet() { var url = baseUrl + $"/latest/0?a=1&b=2"; var httpMessage = new ApiGateWayHttpRequestMessage(HttpMethod.Get, url, AppKey, AppSecret); //1.first add custom headers var timeStamp = GetSecondTimeStamps(DateTime.Now); httpMessage.Headers.Add("timeStamp", timeStamp.ToString()); //2.add the ali header httpMessage.AddAliHeader(); //3.send the request var response = httpClient.SendAsync(httpMessage).Result; Assert.IsTrue(response.IsSuccessStatusCode); }
public void TestPostJson() { var url = baseUrl + $"/latest/0"; var httpMessage = new ApiGateWayHttpRequestMessage(HttpMethod.Post, url, AppKey, AppSecret); //add custom headers var timeStamp = GetSecondTimeStamps(DateTime.Now); httpMessage.Headers.Add("timeStamp", timeStamp.ToString()); //build content httpMessage.Content = new StringContent("{'a':'1'}", Encoding.UTF8, "application/json"); httpMessage.AddAliHeader(); var response = httpClient.SendAsync(httpMessage).Result; Assert.IsTrue(response.IsSuccessStatusCode); }