簡體   English   中英

如何在 .core (POSTMAN) 中的 [FromBody](raw) 中發布 json 參數

[英]How to post json parameter in [FromBody](raw) in .core (POSTMAN)

我在 .core 3 項目中有一個方法[Post] 以及:我將使用帶有 10 個 json 參數的 post:

[
  {
    "os": "android",
    "type": "www",
    "versionCode": 123,
    "operand": "fofdr",
    "forceUpdate": false,
    "title": "dsfs",
    "message": "fdsf",
    "action": "act",
    "positiveButton": "btn1",
    "negativeButton": "test",
    "messageType": "sadad"
  }
]

和:

 [HttpPost]
        [Route("CreateStartMessage")]
        public IActionResult CreateStartMessage([FromBody] string os, string type, int versionCode, string operand, bool forceUpdate, string title,
            string message, string action, string positiveButton, string negativeButton,string messageType)
        {
            try
            {

             ...
                return Ok(resultApi);
            }



        }

我如何使用 POSTMAN 將 json 參數傳遞給這個方法 api?

這應該適用於@Christoph Lütjen 的提示:

class MyMessage {
  public string Os { get; set; }
  public string Type { get; set; }
  public int VersionCode { get; set; }
  public string Operand { get; set; }
  public bool ForceUpdate { get; set; }
  public string Title { get; set; }
  public string Message { get; set; }
  public string Action { get; set; }
  public string PositiveButton { get; set; }
  public string NegativeButton { get; set; }
  public string MessageType { get; set; }
}

[HttpPost]
[Route("CreateStartMessage")]
public IActionResult CreateStartMessage([FromBody]MyMessage clientMessage) {
    return Ok(resultApi);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM