作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我跑 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>
[...]
$ 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/
我是一名优秀的程序员,十分优秀!