如何在Amazon Pinpoint中创建端点并发送消息

时间:2019-04-24 01:36:20

标签: python python-3.x amazon-web-services boto3 aws-pinpoint

im试图使用boto3向其发送消息,但update_endpoint和send_messages的功能不断使我返回资源未找到

client = boto3.client('pinpoint', region_name="us-east-1", aws_access_key_id="xxx", aws_secret_access_key="xxx")

client.update_endpoint(ApplicationId="xxx",EndpointId='+573163781068',EndpointRequest={'Address': '+573163781068','ChannelType': 'SMS','Location': {'Country': 'CO'}})

client.send_messages(ApplicationId="xxx", MessageRequest={'Addresses': {'+573163781068': {'ChannelType': 'SMS'}}, 'MessageConfiguration': {'SMSMessage': {'Body': 'hola desde libreria', 'MessageType': 'TRANSACTIONAL'}}})

返回我的错误是:

Traceback (most recent call last):
 File "<console>", line 1, in <module>
 File "/Applications/MAMP/htdocs/enviroment/kleanapp/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
 File "/Applications/MAMP/htdocs/enviroment/kleanapp/lib/python3.7/site-packages/botocore/client.py", line 661, in _make_api_call
  raise error_class(parsed_response, operation_name)
botocore.errorfactory.NotFoundException: An error occurred (NotFoundException) when calling the SendMessages operation: Resource not found

在此先感谢您的帮助

1 个答案:

答案 0 :(得分:0)

您不需要端点即可发送消息。只需删除update_endpoint行即可。

NotFoundException可能来自找不到应用程序ID。请确保您在正确的区域中指定了正确的应用程序ID值。

您可以使用以下命令找到特定区域的有效应用程序及其ID的列表:

aws --region us-east-1 pinpoint get-apps