Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在.core(POSTMAN)中的[FromBody](原始)中发布json参数_C#_Asp.net Core - Fatal编程技术网

C# 如何在.core(POSTMAN)中的[FromBody](原始)中发布json参数

C# 如何在.core(POSTMAN)中的[FromBody](原始)中发布json参数,c#,asp.net-core,C#,Asp.net Core,我在.core3项目中有一个方法[Post]。以及: 我将使用带有10个json参数的post: [ { "os": "android", "type": "www", "versionCode": 123, "operand": "fofdr", "forceUpdate": false,

我在.core3项目中有一个方法
[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"
  }
]
以及:


如何使用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);
}

文档中描述了如何使用邮递员发送json:-但您的json将无法与您的邮件签名一起使用。您没有10个参数,只有一个参数,它是一个对象列表,对象具有属性os、类型。。。您需要创建一个类来建模json结构。clientMessage我定义了谁?danke mein Freund!
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);
}