无法使用 Python 3 将 MessageAttributes 发送到 AWS SQS
Unable to send the MessageAttributes to AWS SQS using Python 3
我正在尝试使用 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'
}
}
)
我正在尝试使用 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'
}
}
)