webapi2 绑定不起作用
webapi2 Binding not working
我是网络新手api 2,正在尝试让我的 api 绑定到下面的这个调用。
谁能看出我做错了什么?
[RoutePrefix("myjohndeere")]
public class ApiMyJohnDeereController : ApplicationController
{
[HttpGet, Route("authenticated/{callbackId}")]
[SwaggerResponse(HttpStatusCode.OK, Type = typeof(ApiResponseModel))]
[SwaggerResponse(HttpStatusCode.InternalServerError, "An unknown error occurred")]
[SwaggerResponse(HttpStatusCode.BadRequest, "Missing FieldMappings")]
public IHttpActionResult Authenticated(string callbackId,[FromUri]string oauth_token, [FromUri]string oauth_verifier)
{
...
}
首先,您错过了路线中的 'api'。
像这样尝试
然后,从您的控制器方法中删除 FromUri 属性。仅读取值类型的查询字符串时不需要该属性。
像这样尝试
public IHttpActionResult Authenticated(string callbackId, string oauth_token, string oauth_verifier)
问题是 Azure API 网关仍设置为使用 PUT 而不是 GET。
我是网络新手api 2,正在尝试让我的 api 绑定到下面的这个调用。
谁能看出我做错了什么?
[RoutePrefix("myjohndeere")]
public class ApiMyJohnDeereController : ApplicationController
{
[HttpGet, Route("authenticated/{callbackId}")]
[SwaggerResponse(HttpStatusCode.OK, Type = typeof(ApiResponseModel))]
[SwaggerResponse(HttpStatusCode.InternalServerError, "An unknown error occurred")]
[SwaggerResponse(HttpStatusCode.BadRequest, "Missing FieldMappings")]
public IHttpActionResult Authenticated(string callbackId,[FromUri]string oauth_token, [FromUri]string oauth_verifier)
{
...
}
首先,您错过了路线中的 'api'。
像这样尝试
然后,从您的控制器方法中删除 FromUri 属性。仅读取值类型的查询字符串时不需要该属性。
像这样尝试
public IHttpActionResult Authenticated(string callbackId, string oauth_token, string oauth_verifier)
问题是 Azure API 网关仍设置为使用 PUT 而不是 GET。