邮递员响应:找到与请求匹配的多个操作
Postman response: Multiple actions were found that match the request
我有两个同名但参数不同的方法,应该return一个HttpResponseMessage
public HttpResponseMessage ReceivedData(JObject jsonData)
和
public HttpResponseMessage ReceivedData(double longitude, double latitude)
如果我从 Postman
发出 POST 请求,第二个请求使用
http://localhost:6296/api/MyController/ReceivedData?longitude=0&latitude=0
一切正常,但第一个
http://localhost:6296/api/MyController/ReceivedData
和JSONBody{"longitude":0, "latitude":0, "otherData":"test"}
我得到
"ExceptionMessage": "Multiple actions were found that match the request
我不明白我做错了什么。
试试这个
[HttpPost]
public HttpResponseMessage ReceivedData(JObject jsonData)
[HttpGet]
public HttpResponseMessage ReceivedData(double longitude, double latitude)
或者如果您仍然希望两者都 post,请将第一个的操作更改为 ReceivedJsonData
[HttpPost("~/api/My/ReceivedJsonData")]
public HttpResponseMessage ReceivedData(JObject jsonData)
我有两个同名但参数不同的方法,应该return一个HttpResponseMessage
public HttpResponseMessage ReceivedData(JObject jsonData)
和
public HttpResponseMessage ReceivedData(double longitude, double latitude)
如果我从 Postman
发出 POST 请求,第二个请求使用
http://localhost:6296/api/MyController/ReceivedData?longitude=0&latitude=0
一切正常,但第一个
http://localhost:6296/api/MyController/ReceivedData
和JSONBody{"longitude":0, "latitude":0, "otherData":"test"}
我得到
"ExceptionMessage": "Multiple actions were found that match the request
我不明白我做错了什么。
试试这个
[HttpPost]
public HttpResponseMessage ReceivedData(JObject jsonData)
[HttpGet]
public HttpResponseMessage ReceivedData(double longitude, double latitude)
或者如果您仍然希望两者都 post,请将第一个的操作更改为 ReceivedJsonData
[HttpPost("~/api/My/ReceivedJsonData")]
public HttpResponseMessage ReceivedData(JObject jsonData)