Amazon SNS now supports custom `Content-Type` headers for HTTP messages delivered from topics. Here's the announcement: https://aws.amazon.com/about-aws/whats-new/2023/03/amazon-sns-content-type-request-headers-http-s-notifications/
You simply have to modify the `DeliveryPolicy` attribute of your Amazon SNS subscription, setting the `headerContentType` property to `application/json`, `application/xml`, or any other value supported. You can find all values supported here: https://docs.aws.amazon.com/sns/latest/dg/sns-message-delivery-retries.html#creating-delivery-policy
{
"healthyRetryPolicy": {
"minDelayTarget": 1,
"maxDelayTarget": 60,
"numRetries": 50,
"numNoDelayRetries": 3,
"numMinDelayRetries": 2,
"numMaxDelayRetries": 35,
"backoffFunction": "exponential"
},
"throttlePolicy": {
"maxReceivesPerSecond": 10
},
"requestPolicy": {
"headerContentType": "application/json"
}
}
You set the `DeliveryPolicy` attribute by calling the `SetSubscriptionAttributes` API action: https://docs.aws.amazon.com/sns/latest/api/API_SetSubscriptionAttributes.html
As of today, Amazon SNS now supports custom `Content-Type` headers for HTTP messages delivered from topics. Here's the feature announcement: https://aws.amazon.com/about-aws/whats-new/2023/03/amazon-sns-content-type-request-headers-http-s-notifications/
As you can see, you basically need to modify the `DeliveryPolicy` attribute of your Amazon SNS subscription, setting the `headerContentType` property to `application/json`, `application/xml`, or any other value supported. You can find all values supported here: https://docs.aws.amazon.com/sns/latest/dg/sns-message-delivery-retries.html#creating-delivery-policy
Here's a sample `DeliveryPolicy` for reference:
{
"healthyRetryPolicy": {
"minDelayTarget": 1,
"maxDelayTarget": 60,
"numRetries": 50,
"numNoDelayRetries": 3,
"numMinDelayRetries": 2,
"numMaxDelayRetries": 35,
"backoffFunction": "exponential"
},
"throttlePolicy": {
"maxReceivesPerSecond": 10
},
"requestPolicy": {
"headerContentType": "application/json"
}
}
Hope it helps!