Reputation: 490
I am trying to write to an SQS message attributes using boto3 library.
import boto3
sqs = boto3.client('sqs')
response = sqs.send_message(
QueueUrl = 'https://queue.amazonaws.com/xxxxx/test',
MessageBody='test01',
MessageAttributes={
'from': {
'StringValue': '2019-12-11',
'DataType': 'string'
}
}
)
But I got error message:
botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the SendMessage operation: The type of message (user) attribute 'from' is invalid. You must use only the following supported type prefixes: Binary, Number, String.
I also tried several ways but it did not work too. Could anyone please help me to fix that error?
I also would highly appreciate if there is another way to do it? Thanks!
Upvotes: 5
Views: 7121
Reputation: 781
This should fix your code but right way is to have a look at this
import boto3
sqs = boto3.client('sqs')
response = sqs.queue.send_message(
QueueUrl = 'https://queue.amazonaws.com/xxxxx/test',
MessageBody='test01',
MessageAttributes={
'from': {
'StringValue': '2019-12-11',
'DataType': 'String'
}
}
)
Upvotes: 5