能否通过POST请求体向SQS URL发送消息,无需API网关?
Absolutely! You can totally send your message payload via a POST request body to SQS's SendMessage API—no AWS API Gateway required. This is perfect for your high-throughput use case, and here's how to make it work:
1. Use POST with form-encoded request body
SQS fully supports POST requests where you pass API parameters (like Action and MessageBody) in the request body instead of the URL query string. You just need to set the Content-Type header to application/x-www-form-urlencoded.
For example, instead of appending parameters to your URL, your request would look like this:
- URL:
https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue - Method: POST
- Headers:
Content-Type: application/x-www-form-urlencoded - Request Body:
Action=SendMessage&MessageBody=This+is+a+test+message
This avoids URL length limitations and works seamlessly with high-throughput traffic.
2. Handling JSON payloads
Since your external service sends JSON payloads, you just need to wrap that JSON as the value of the MessageBody parameter (and URL-encode it if needed). SQS will store the JSON string as the message body, which you can parse later when receiving messages.
Here's an example of a valid request body for a JSON payload:
Action=SendMessage&MessageBody={"orderId":"123","status":"processing"}
If you're using a tool like curl, this would look like:
curl -X POST https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "Action=SendMessage&MessageBody={\"orderId\":\"123\",\"status\":\"processing\"}"
Note: Make sure any special characters in your JSON (like quotes) are properly escaped or URL-encoded to avoid parsing errors.
3. Authentication reminder
Just like your original GET request, POST requests to SQS require valid AWS authentication (using Signature Version 4). If your existing setup already handles signing requests for the GET method, you can reuse that logic for POST—no extra changes needed here. Avoid using unauthenticated public queues in production environments for security.
This approach keeps things simple, leverages SQS's native API, and handles high-throughput traffic without needing to spin up an API Gateway.
内容的提问来源于stack exchange,提问作者Andrew Wei

