【问题标题】:How to add headers to HttpRequestMessageProperty in UWP如何在 UWP 中向 HttpRequestMessageProperty 添加标头
【发布时间】:2016-04-08 13:57:12
【问题描述】:

我正在将一些代码从原生 C# 项目迁移到通用 Windows 项目并尝试执行以下操作:

HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();

httpRequestProperty.Headers.Add("X-EBAY-SOA-SECURITY-APPNAME", "APPID");
httpRequestProperty.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "findItemsByKeywords");
httpRequestProperty.Headers.Add("X-EBAY-SOA-GLOBAL-ID", "EBAY-US");

OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;

虽然在 C# 本机中我能够将标题添加到集合中,但在 UWP 中这是不可能的。 System.ServiceModel.Http 版本 4.0.1.0 中的 HttpRequestMessageProperty.Headers 似乎只是一个 Getter...

UWP 中的替代方案是什么? 如何将标题添加到集合中?

【问题讨论】:

    标签: c# uwp universal ebay-api


    【解决方案1】:

    嗯...谷歌搜索:

    httpRequestProperty.Headers["X-EBAY-SOA-SECURITY-APPNAME"] = "APPID";
    httpRequestProperty.Headers["X-EBAY-SOA-OPERATION-NAME"] = "findItemsByKeywords";
    httpRequestProperty.Headers["X-EBAY-SOA-GLOBAL-ID"] = "EBAY-US";
    

    【讨论】:

      猜你喜欢
      • 2019-08-08
      • 1970-01-01
      • 2017-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-10
      相关资源
      最近更新 更多