Reputation: 3
Could you please help me with that? I did try my best to get this function up and running?
Here are the articles that I viewed- https://www.zoho.com/creator/help/script/invoking-a-function.html
curl --location --request POST 'https://gw.cmtelecom.com/v1.0/message' \
--header 'Content-Type: application/json' \
--data-raw '{
"messages": {
"authentication": {
"producttoken": "test"
},
"msg": [
{
"from": "00919538893819",
"to": [
{
"number": "00918892449978"
}
],
"body": {
"type": "auto",
"content": "This is a WhatsApp message"
},
"allowedChannels": [
"WhatsApp"
],
"richContent": {
"conversation": [
{
"template": {
"whatsapp": {
"namespace": "5c198301_106c_4fc2_a2f6_7556d8847746",
"element_name": "otp",
"language": {
"policy": "deterministic",
"code": "en"
},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "Dhanush"
},
{
"type": "text",
"text": "627728289"
}
]
}
]
}
}
}
]
}
}
]
}
}'
Is there a different way we could execute this?
Upvotes: 0
Views: 3296
Reputation: 845
You should define a variable with the JSON data first, and then pass the data as a string to invokeUrl.
See the following example:
void APICall()
{
data = {"messages":{"authentication":{"producttoken":"******"},"msg":{{"from":"00919538893819","to":{{"number":"00918892449978"}},"body":{"type":"auto","content":"This is a WhatsApp message"},"allowedChannels":{"WhatsApp"},"richContent":{"conversation":{{"template":{"whatsapp":{"namespace":"5c198301_106c_4fc2_a2f6_7556d8847746","element_name":"otp","language":{"policy":"deterministic","code":"en"},"components":{{"type":"body","parameters":{{"type":"text","text":"Dhanush"},{"type":"text","text":"627728289"}}}}}}}}}}}}};
response = invokeUrl
[
url: "https://gw.cmtelecom.com/v1.0/message"
type: POST
parameters: data.toString()
headers: {"Content-Type": "application/json"}
];
info response;
}
Please, do not post API Authentication Tokens in your quetions!
Upvotes: 2