gpt4 book ai didi

json - 如何将 JSON 文件作为 MessageBody for Amazon SQS 发布?

转载 作者:行者123 更新时间:2023-12-04 12:49:54 26 4
gpt4 key购买 nike

我跑 ElasticMQ在本地模拟 Amazon SQS,我想将 JSON 文件作为 MessageBody 发送。这是一个有效的示例请求:

$ curl 'http://localhost:9324/queue/foo?Action=SendMessage&MessageBody={"action":"hey"}'

<SendMessageResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/">
<SendMessageResult>
[...]

如果我想发送一个大的 JSON 文件,将其作为 POST 会更有意义,如下所示:
$ curl 'http://localhost:9324/queue/foo?Action=SendMessage' -X POST \
-H "Content-Type: application/json" --data @./bigdata.json

There was an internal server error.

有没有办法使这项工作?

最佳答案

这是一个旧的,但我最近在这方面做得不够,想添加我发现的内容。
如果您将 Content-Type 设置为 text/plain,则消息会成功,这与 json 数据负载非常不直观。

$ curl -X "POST" "https://sqs.us-east-1.amazonaws.com/136525823465/rfidsqs?Action=SendMessage" -H 'Content-Type: text/plain' -d '{"testKey1": 123456,"testKey2": "5sUXJYodEUVvQwVT"}'
回应
<SendMessageResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/">
<SendMessageResult>
<MessageId>ba2f6498-0e6b-48cd-bd8f-027d911082b6</MessageId>
<MD5OfMessageBody>4c8132a52a4e6f0bb5ecbe758502c69f</MD5OfMessageBody>
</SendMessageResult>
<ResponseMetadata>
<RequestId>ddc02593-8757-5d0b-a780-72183ae5f517</RequestId>
</ResponseMetadata>
</SendMessageResponse>

关于json - 如何将 JSON 文件作为 MessageBody for Amazon SQS 发布?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40505698/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com