【发布时间】:2014-01-20 11:27:21
【问题描述】:
我创建了一个 web api,其中包含方法:
POST Settings/SetPropertyValue?propertyName={propertyName}
public object SetPropertyValue(string propertyName, object propertyValue)
{
switch (propertyName)
{
//Do the property assignment
}
}
当我访问帮助页面时,它显示以下
当我尝试从提琴手调用该方法时,使用 XML 示例,它工作正常,对象 propertyValue 等于 POST 值。
XML POST 示例:
POST http://localhost:99/webapi/Settings/SetPropertyValue?propertyName=myProperty HTTP/1.1
Content-Type: text/xml; charset=UTF-8
Host: localhost:99
Expect: 100-continue
Connection: Keep-Alive
<anyType>
true
</anyType>
但是在这种情况下如何 POST JSON? JSON 是否处理“简单”数据类型,如对象或字符串?
【问题讨论】:
标签: c# json asp.net-web-api