webapi2 绑定不起作用

webapi2 Binding not working

我是网络新手api 2,正在尝试让我的 api 绑定到下面的这个调用。

谁能看出我做错了什么?

致电: https://blabla.azurewebsites.net/myjohndeere/authenticated/e33dd8f74c97474d86c75b00dd28ddf8?oauth_token=1539dccf-d935-4d9e-83be-e00f76cabbb9&oauth_verifier=B22dWL

[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'。

像这样尝试

https://blabla.azurewebsites.net/api/myjohndeere/authenticated/e33dd8f74c97474d86c75b00dd28ddf8?oauth_token=1539dccf-d935-4d9e-83be-e00f76cabbb9&oauth_verifier=B22dWL

然后,从您的控制器方法中删除 FromUri 属性。仅读取值类型的查询字符串时不需要该属性。

像这样尝试

public IHttpActionResult Authenticated(string callbackId, string oauth_token, string oauth_verifier)

问题是 Azure API 网关仍设置为使用 PUT 而不是 GET。