3

im trying to use boto3 to send messages with pinpoint to, but the functions for update_endpoint and send_messages keeps return me Resource not found

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'}}})

the error that returns me is:

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

in advance thanks for your help

beren5000
  • 100
  • 10

1 Answers1

1

You don't need an endpoint to send a message. Just remove the update_endpoint line.

The NotFoundException can come from the Application ID not being found. Please make sure you are specifying the correct application ID value in the correct region.

You can find a list of valid applications and their IDs for a particular region using the following command:

aws --region us-east-1 pinpoint get-apps
JD D
  • 7,398
  • 2
  • 34
  • 53
  • thanks JD, but still does not send the message, still saids ""operation: Resource not found"" – beren5000 May 27 '19 at 23:32
  • can you send the entire error message? is SMS turned on for your application? do you have a long code created? – JD D May 28 '19 at 00:18
  • Hello JD, i have edited the post with the full traceback of the error, also, yes, SMS is turned on for my application, and works sending messages via the example in the AWS console page, when you said long code, what do you mean?, those are the only lines that i'm using in python shell. – beren5000 May 28 '19 at 21:16
  • looking at your command, the only thing that could cause that is your application ID being incorrect, I have updated my answer with more info on that – JD D May 28 '19 at 23:35
  • Hello JD, i the credentials seems to be fine, i see the user registered for use in the pinpoint endpoints, with full access, and i see that update_endpoint is working fine, thanks again for your answers, but still send_messages isn't working – beren5000 Jun 11 '19 at 19:59
  • Did you sanity check your application id you have in the request? (Your example has xxx). I could recreate that error when I sent a message with an invalid application id. – JD D Jun 12 '19 at 00:32
  • sorry for ask maybe a basic question but, how do i sanity check the app id? – beren5000 Jun 12 '19 at 16:51
  • in pinpoint, under all projects, make sure that the "Project ID" listed for your project is the "ApplicationId" you are passing in your requests – JD D Jun 12 '19 at 16:59
  • i have double checked the project id, the user, access key and access secret key, and they seems to be ok, i wish i could show you screenshots for my aws console but i can't because is the company aws, could be another kind of id that is interfering? – beren5000 Jun 12 '19 at 20:32