参数在webapi中没有价值

时间:2017-02-28 07:33:24

标签: c# .net asp.net-web-api swagger

我试图通过swagger调用服务,方法是传递XML格式的参数。

方法正在命中,但传递的参数为空

表示“xlff”为空白。你有什么问题我知道吗

/// <summary>
    /// Get or insert blog comments which is approved based on blogs
    /// </summary>
    /// <remarks> Get or insert blog comments which is approved based on blogs</remarks>
    /// <param name="xlf">The comment.</param>
    /// <response code="200">Get approved blog comments</response>
    /// <response code="404">Not found</response>
    /// <returns>IHttpActionResult</returns>
    [Route("api/smartling/ProcessSmartlingTranslation")]
    [VersionedRoute("", 1)]
    [ResponseType(typeof(HttpResponseMessage))]
    [HttpPost]
    public IHttpActionResult ProcessSmartlingTranslation([FromBody]xliff xlff)
    {
        return Content(HttpStatusCode.BadRequest, "Any object");
    }



 /// <summary>
    /// XliffModel created
    /// </summary>
    public class xliff
    {
        /// <summary>
        /// file getter setter method
        /// </summary>
        public string file { get; set; }
        /// <summary>
        /// body getter setter method
        /// </summary>
        public string body { get; set; }
    }

Swagger

1 个答案:

答案 0 :(得分:0)

您的参数内容类型是application / json,但您正在发送xml。您应该将内容类型更改为application / xml。