我有這個控制器
public async Task<ActionResult> SubmitFormAsync([FromBody] Dictionary<string, string> input, Guid formGuid)
我通過郵遞員提供輸入
{
"input": {
"firstname": "Toren",
"jobtitle": "Activist",
"lastname": "SO",
"message": "",
"phone": " 123455667"
}
}
但我在郵遞員中不斷收到這個錯誤
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "00-79f401cda7f4cdb640dbd8c95dc851d5-a6b4228c3e1675ba-00",
"errors": {
"input": [
"The input field is required."
],
"$.input": [
"The JSON value could not be converted to System.Collections.Generic.Dictionary`2[System.String,System.String]. Path: $.input | LineNumber: 1 | BytePositionInLine: 12."
]
}
}
我知道這意味著我的輸入是錯誤的,但為什么是錯誤的我無法弄清楚。
uj5u.com熱心網友回復:
您需要發布正文,沒有以下密鑰 -
{
"firstname": "Toren",
"jobtitle": "Activist",
"lastname": "SO",
"message": "",
"phone": " 123455667"
}
并在查詢字串中傳遞 guid。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/524381.html
標籤:网json控制器
上一篇:C#錯誤:資料源是無效型別。它必須是IListSource、IEnumerable或IDataSource
下一篇:如何獲得特定屬性#C的代碼覆寫率
