【发布时间】:2020-01-25 20:29:45
【问题描述】:
我正在使用 C# 中的 HttpClient 将 JSON LD 数据发送到 webapi 端点。 我收到错误不支持的媒体类型格式化程序。 我发送的数据是 JSONLD 作为字符串:
string data = @"{
""@type"": ""vcx:blah"",
""vcx:key"": ""blah"",
""vcx:value"": ""blah""
} ";
httpClient.PostAsync(uri, new StringContent(data));
在 api 方面,是 web api。在 Global.asax.cs 我有以下内容:
GlobalConfiguration.Configuration.Formatters.Clear();
GlobalConfiguration.Configuration.Formatters.Add(new
JsonMediaTypeFormatter());
即使我删除了格式化程序的清除,我在调用应用程序上也会遇到同样的错误。
有人知道解决办法吗?
【问题讨论】:
标签: c# asp.net-web-api json-ld mediatypeformatter