1

I'm trying to send a message to AWS SQS from bash script using curl. I took this article as a base. As a result I'm building the following request: https://sqs.eu-west-1.amazonaws.com/[MY_QUEUE_NAME]?Action=SendMessage&MessageBody=[MY_MESSAGE]

And here starts the most complicated. Whenever I'm using a plain text as MY_MESSAGE everything works perfect and message is delivered to SQS, but I want to send a JSON: {"mahine": "SOME_MACHINE", "user": "SOME_USER"}

I haven't found a way to use curly braces in GET request as HTTP parameter. How can I make {} symbols be recognized as simple text?

1 Answer 1

4

Really you should be adding it to the request body in a POST with something like this:

curl -H "Content-Type: application/json" \
     -X POST \
     -d '{"machine":"SOME_MACHINE","user":"SOME_USER"}' \
     https://sqs.eu-west-1.amazonaws.com/[MY_QUEUE_NAME]?Action=SendMessage

You can however add JSON to a GET request in the URL but you will need to encode it first using percent escaping (i.e. %20 escapes a space). { and } are not valid in a URL and need to be encoded to %7B and %7D receptively.

You can use this URL encoder to encode your JSON to an acceptable format for the URL.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot, after encoding the whole message issue was resolved

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.