如何使用azure SDK for .net在Azure Data Factory Web活动中设置标头

问题描述 投票:0回答:1

我只是想知道如何将标题添加到azure数据工厂Web活动中。我试过下面的代码:

                new WebActivity()
                {
                    Name = "Authenticating",
                    Url = "xxxxxxxxxxxxx",
                    Method = "POST",
                    Headers =  " \"Content-Type\": \"application/x-www-form-urlencoded\""
                },

但是,代码将导致

"headers": { "0": " ", "1": "\"", "2": "C", "3": "o", "4": "n", "5": "t", "6": "e", "7": "n", "8": "t", "9": "-", "10": "T", "11": "y", "12": "p", "13": "e", "51": "\"", "seed": 1840253349 },

他们说,我去了他们的源代码

/// Gets or sets represents the headers that will be sent to the
/// request. For example, to set the language and type on a request:
/// "headers" : { "Accept-Language": "en-us", "Content-Type":
/// "application/json" }. Type: string (or Expression with resultType
/// string).

我也尝试在字符串中使用{},例如:

Headers =  " { \"Accept-Language\": \"en-us\", \"Content-Type\":\r\n/// \"application/json\" }",

任何的想法?

azure azure-data-factory
1个回答
0
投票

我们应该传入一个Json对象而不是字符串。刚刚将代码更改为下面,它工作正常。

Headers =JObject.Parse(@"{ 'Content-Type': 'application/x-www-form-urlencoded'}") 
© www.soinside.com 2019 - 2024. All rights reserved.