[英]webapi2 Binding not working
我是webapi 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”。
像這樣嘗試
然后,從控制器方法中刪除FromUri屬性。 僅讀取值類型的查詢字符串時,不需要該屬性。
像這樣嘗試
public IHttpActionResult Authenticated(string callbackId, string oauth_token, string oauth_verifier)
問題是Azure API網關仍設置為使用PUT而不是GET。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.