将原始文本请求参数发送到HttpClient PostAsync方法

时间:2018-11-26 13:24:35

标签: c# http httpwebrequest httpclient webrequest

这是我为从Httpclient Async方法获取响应而编写的代码。

标题是 接受:application / vnd.citrix.requesttokenresponse + xml,application / vnd.citrix.requesttokenchoices + xml

Content-Type:应用程序/vnd.citrix.requesttoken+xml

请求正文:原始-文本

<?xml version="1.0" encoding="utf-8"?>
<requesttoken xmlns="http://citrix.com/delivery-services/requesttoken">
 <for-service>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-Realm-token</for-service>
<for-service-url>http:/Storeaddress/resources/v2</for-service-url>
<reqtokentemplate />
<requested-lifetime>1.00:00:00</requested-lifetime>
</requesttoken>

获取响应的代码

 HttpClient client = new HttpClient();

 public async void getRequestTokenchoicesAsync()
        {
            iaLogging.CoreLog(IALogging.LOG_DEBUG, "Getting Request token choices using Http Basic");

            client.DefaultRequestHeaders.Add("Accept","application/vnd.citrix.requesttokenresponse+xml, application/vnd.citrix.requesttokenchoices+xml");
            client.DefaultRequestHeaders.Add("Content-Type","application/vnd.citrix.requesttoken+xml");


            var response = await client.PostAsync(getRequestChoices.ToString(), null);
            var responseString = await response.Content.ReadAsStringAsync();

            iaLogging.CoreLog(IALogging.LOG_DEBUG, "Getting Request token choices Header = " + response);
            iaLogging.CoreLog(IALogging.LOG_DEBUG, "Response from Getting Request token choices values Storefront dll" + responseString);
        }

我想将上述参数发送到PostAsync而不是null。

请帮帮我。

0 个答案:

没有答案