Apologies for a basic question. As I have not got proper solution from Freshchat support team, I am posting it to Dev. community.
Simply I am trying to send a WhatsApp Proactive message (template approved) using python requests library. But I am getting following error
b'{"success":false,"errorCode":415,"errorMessage":"Please provide a valid value for Content-Type header","errorData":null,"errorName":null}'
When I am sending this message using “WhatsApp Proactive Messaging app” from FreshChat marketplace it’s getting delivered. Don’t know what I am missing in the body for the api call.
Below is the body for the api call.
{
"from": {
"phone_number": "+447946000000"},
"provider": "whatsapp",
"to": [{
"phone_number": "+44740000000"
}],
"data": {
"message_template": {
"storage": "conversation",
"template_name": "payment_confirmation",
"namespace": "50d678e9_57a8_4275_bc87_xxxxxxxx",
"language": {
"policy": "deterministic",
"code": "en"
},
"rich_template_data": {
"header": {
"type": "none"},
"body": {
"params": [
{"data": "Variable 1"},
{"data": "Variable 2"},
{"data": "Variable 3"}
]}
}
}
}
}
Here’s the python code which is calling api endpoint
import requests
headers = {
'accept': 'application/json',
'Authorization': 'Bearer ' + apitoken}
response = requests.post('https://api.freshchat.com/v2/outbound-messages/whatsapp', headers=headers, data=data)
Thanks and Regards