简体   繁体   English

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

[英]How to set header in Azure Data Factory web activity by azure SDK for .net

I am just wondering how can i add header to the azure data factory web activity. 我只是想知道如何将标题添加到Azure数据工厂Web活动中。 I tried code below: 我在下面尝试了代码:

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

However, the code will result in 但是,代码将导致

"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 },

I went to their source code, they said 他们说,我去了他们的源代码

/// 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).

I also tried with {} within the string, like: 我也尝试在字符串中使用{},例如:

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

Any idea? 任何想法?

We should pass in a Json object instead of string. 我们应该传递一个Json对象而不是字符串。 Just changed the code to below and it worked. 刚刚将代码更改为下面,它工作正常。

Headers =JObject.Parse(@"{ 'Content-Type': 'application/x-www-form-urlencoded'}") 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM