WebClient.UploadString不提供json

时间:2018-02-16 14:04:25

标签: c# .net

我正在尝试使用代码,但它在HTML中为我提供了响应字符串,但我想在JSON中使用它。

string _sendGridAPIUrl = "http://localhost/MyServiceHost/Testing/TestService";
            string data = "{\"applicateRegionCode\":\"N\",\"MyID\":\"737\", \"sourceVersion\"=\"6\", \"DivisionName\":\"AE Name\",\"JobTaxName\":\"Test List\",\"Username\":\"jnam\",\"Schema\":\"TTT\"}";
            using (WebClient client = new WebClient())
            {
                client.Headers.Add("Content-Type", "application/json");
                client.Headers.Add("id", "13a94672-08k6-46a8-89cc-ba3217721504");
                client.Headers.Add("key", "354C5TA7-330D-40DC-8524-0000500DE654");

                var str = client.UploadString(_sendGridAPIUrl, data);

0 个答案:

没有答案