如果我将方法设置为:
[HttpPut({path})]
public async Task<IActionResult> DoSomething(sting path, IEnumerable<KeyValuePair<string,string>> values)
查询字符串应该是什么样的? (就好像我在浏览器中输入它们进行测试一样)
修改
我已经尝试了
http://localhost:12345/APath?values[0].Key=AKey&values[0].Value=MyValue
但收到404。
答案 0 :(得分:0)
我将发布一个工作示例供您参考:
public class MyPerformerController: ApiController {
[HttpPut("update/{myPath}")]
public IActionResult PerformUpdate(string myPath, [FromBody]MyDataTransferObject myDto) {
}
}
public class MyDataTransferObject {
public string SomeProperty { get; set; }
public string Salutation { get; set; }
public IEnumerable<KeyValuePair<string, string>> Pairs { get; set; }
}
执行PUT
来电:http://localhost:12345/api/myperformer/update/aPath
body
:json格式应为
{
SomeProperty: "asd",
Salutation: "Mr",
Pairs: [
{key: 'key1', value: 'value1'},
{key: 'key2', value: 'value2'},
]
}
请务必设置Content-Type: application/json
和Accept: application/json