- Newest
- Most votes
- Most comments
Thank you for sharing the sample code snippet. Please allow me to share my observations :-
-
NotFoundException
could occur in case if the resource being referenced could not be found. Therefore, Could you please verify whether the parameters such as Pinpoint Application ID (This identifier is displayed as the Project ID on the Amazon Pinpoint console), Region, Object etc. that are being passed are passed as expected ? -
Next, I tried using the following snippet in a Lambda function keeping your your code as a reference and I was able to successfully create/update an endpoint associated with the user ID:
user-20
. I simply added thetry-catch
block andawait
in front of the promise. The following is the sample Lambda function code I used at my end :-
const AWS = require('aws-sdk');
accessKeyId = process.env.ACCESS_KEY_ID,
secretKey = process.env.SECRET_KEY
AWS.config.update({
region: 'ap-southeast-2',
accessKey: accessKeyId,
secretAccessKey: secretKey,
});
const pinpoint = new AWS.Pinpoint({
accessKey: accessKeyId,
secretAccessKey: secretKey,
region: 'ap-southeast-2',
signatureVersion: 'v4',
});
exports.handler = async (event) => {
const endpointAddress = '+91123456778'; // TODO: PLEASE ENTER ENDPOINT'S PHONE NUMBER
console.log(">>>Endpoint Address: ", endpointAddress)
const endpointID = '1234';
console.log(">>>EndpointID: ", endpointID) // TODO: PLEASE ENTER THE ENDPOINT ID
const params = {
ApplicationId: 'abcdefghijkl' // PLEASE ENTER YOUR APPLICATION ID,
EndpointId: endpointID ,
EndpointRequest: {
/* required */
Address: endpointAddress,
ChannelType: 'VOICE',
EndpointStatus: 'ACTIVE',
OptOut: 'NONE',
Location: {
Country: "IN"
},
Demographic: {
Make: 'Apple',
Platform: 'iOS'
},
EffectiveDate: '2022-08-11',
Attributes: {
Interests: ['Technology', 'Music', 'Travel'],
CampaignIdentifier: ['OB']
},
Metrics: {
technology_interest_level: 9,
music_interest_level: 6,
travel_interest_level: 4
},
User: {
UserAttributes: {
firstName: ["Dev"],
lastName: ["A"],
country: ["India"]
},
UserId: "user-20"
}
}
}
try {
const res= await pinpoint.updateEndpoint(params).promise();
console.log(res);
}catch(err){
console.log(err);
}
return endpointID;
};
Lastly, I verified that the updateEndpoint
is working by using the CLI get-endpoint and get-user-endpoints operations and I could notice the endpoint details as a successful response.
Having said that, in case you face further challenges, please feel free to open a support case with AWS using the following link.
I am able to reslove the issue by some modifications i used:
AWS.config.update({
secretAccessKey: process.env.AWS_SECRET_ACCESS,
accessKeyId: process.env.AWS_ACCESS_KEY,
region: 'ap-southeast-2',
});
const pinpoint = new AWS.Pinpoint();
pinpoint.updateEndpoint(params, function (err, data) {
if (err) {
console.log('An error occurred.\n');
console.log(err, err.stack);
} else {
console.log(
'Endpoint added Successfully with endpoint ID ' + endpointID
);
}
});
No need to add credentials in pinpoint object while creation.
Relevant content
- asked 4 days ago
- asked 7 months ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 3 years ago