我正在尝试使用 boto3 库写入 SQS 消息属性。
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'
}
}
)
但是我收到错误信息:
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.
我也尝试了几种方法,但都没有用。 谁能帮我解决这个错误?
如果有另一种方法,我也将不胜感激?谢谢!
最佳答案
这应该可以修复您的代码,但正确的方法是查看 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'
}
}
)
关于python-3.x - 无法使用 Python 3 将 MessageAttributes 发送到 AWS SQS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59252594/