我在.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?
发布于 2020-10-31 05:48:07
这应该与@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);
}https://stackoverflow.com/questions/64615653
复制相似问题