api - URL 参数作为 null 传递,而不是预期传递的参数
问题描述
我观看了有关创建我的第一个 DynamoDb 的视频以及他的 github 代码。我在数据库中添加了三个字段,标题、创建者和正文。当我在 GET url 中将它们传递为
https://localhost:44317/api/dynamodb/putitems?id=4&replyDateTime=63668789020007900&body=ilovelife&title=mytittle&creator=me
它被放置在数据库中:
{
"id": 4,
"replyDateTime": "63668789020007900",
"body": null,
"title": null,
"creator": null
},
这是我添加字段的 C# 代码:
private PutItemRequest RequestBuilder(int id, string replyDateTime, string body, string title, string creator)
{
var item = new Dictionary<string, AttributeValue>
{
{"Id", new AttributeValue {N = id.ToString()}},
{"ReplyDateTime", new AttributeValue {N = replyDateTime}},
{"Body", new AttributeValue {S = body}},
{"Creator", new AttributeValue {S = creator}},
{"Title", new AttributeValue {S = title}}
};
return new PutItemRequest
{
TableName = "BlogDynamoDbTable",
Item = item
};
Item 中的值被发送到数据库但最终为空:
解决方案
我将 API 代码更改为 POST 而不是 GET。在为 NET 3.0 添加另一个用于读取 json 的 nuget 包后,JSON 数据有效
推荐阅读
- webrtc - RTCError:传输通道关闭(数据通道)-JANUS Webrtc 服务器
- ansible - 将 semodule 与 ansible 一起使用
- sql - 如何获得第一行或第二行
- laravel - 为不同类别显示不同的刀片形式
- visual-studio - Visual Studio Monokai 主题
- sql-server - 如何创建 MsSQL 过程以根据其他两个表过滤一个表?
- monaco-editor - 有没有办法隐藏摩纳哥的预览?
- python - 有什么方法可以在 Python 中使用 Sendgrid 向具有多个内容的多个收件人发送邮件?
- c - 就内存使用而言,在 c 上重用变量是否比定义新变量更好?
- css - 如何在 Qualtrics 调查中使用 CSS 代码隐藏 LOGO?