var options = new RestClientOptions("")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("https://{baseUrl}/voice/ivr/1/messages", Method.Post);
request.AddHeader("Authorization", "{authorization}");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
var body = @"{""bulkId"":""BULK-ID-123-xyz"",""messages"":[{""scenarioId"":""6298AA7707903A4ED680B436929681AD"",""from"":""41793026700"",""destinations"":[{""to"":""41793026727""},{""to"":""41793026731""}],""notifyUrl"":""https://www.example.com/voice/advanced"",""notifyContentType"":""application/json"",""callbackData"":""DLR callback data"",""validityPeriod"":720,""sendAt"":""2023-10-03T12:21:00.632+0000"",""retry"":{""minPeriod"":1,""maxPeriod"":5,""maxCount"":5},""record"":false,""deliveryTimeWindow"":{""from"":{""hour"":6,""minute"":0},""to"":{""hour"":15,""minute"":30},""days"":[""MONDAY"",""TUESDAY"",""WEDNESDAY"",""THURSDAY"",""FRIDAY"",""SATURDAY"",""SUNDAY""]}}]}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
curl -L -g 'https://{baseUrl}/voice/ivr/1/messages' \
-H 'Authorization: {authorization}' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"bulkId": "BULK-ID-123-xyz",
"messages": [
{
"scenarioId": "6298AA7707903A4ED680B436929681AD",
"from": "41793026700",
"destinations": [
{
"to": "41793026727"
},
{
"to": "41793026731"
}
],
"notifyUrl": "https://www.example.com/voice/advanced",
"notifyContentType": "application/json",
"callbackData": "DLR callback data",
"validityPeriod": 720,
"sendAt": "2023-10-03T12:21:00.632+0000",
"retry": {
"minPeriod": 1,
"maxPeriod": 5,
"maxCount": 5
},
"record": false,
"deliveryTimeWindow": {
"from": {
"hour": 6,
"minute": 0
},
"to": {
"hour": 15,
"minute": 30
},
"days": [
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY",
"SATURDAY",
"SUNDAY"
]
}
}
]
}'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"bulkId\":\"BULK-ID-123-xyz\",\"messages\":[{\"scenarioId\":\"6298AA7707903A4ED680B436929681AD\",\"from\":\"41793026700\",\"destinations\":[{\"to\":\"41793026727\"},{\"to\":\"41793026731\"}],\"notifyUrl\":\"https://www.example.com/voice/advanced\",\"notifyContentType\":\"application/json\",\"callbackData\":\"DLR callback data\",\"validityPeriod\":720,\"sendAt\":\"2023-10-03T12:21:00.632+0000\",\"retry\":{\"minPeriod\":1,\"maxPeriod\":5,\"maxCount\":5},\"record\":false,\"deliveryTimeWindow\":{\"from\":{\"hour\":6,\"minute\":0},\"to\":{\"hour\":15,\"minute\":30},\"days\":[\"MONDAY\",\"TUESDAY\",\"WEDNESDAY\",\"THURSDAY\",\"FRIDAY\",\"SATURDAY\",\"SUNDAY\"]}}]}");
Request request = new Request.Builder()
.url("https://{baseUrl}/voice/ivr/1/messages")
.method("POST", body)
.addHeader("Authorization", "{authorization}")
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
Response response = client.newCall(request).execute();
1
2
3
4
5
6
7
8
9
10
11
12
13
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://{baseUrl}/voice/ivr/1/messages"
method := "POST"
payload := strings.NewReader(`{"bulkId":"BULK-ID-123-xyz","messages":[{"scenarioId":"6298AA7707903A4ED680B436929681AD","from":"41793026700","destinations":[{"to":"41793026727"},{"to":"41793026731"}],"notifyUrl":"https://www.example.com/voice/advanced","notifyContentType":"application/json","callbackData":"DLR callback data","validityPeriod":720,"sendAt":"2023-10-03T12:21:00.632+0000","retry":{"minPeriod":1,"maxPeriod":5,"maxCount":5},"record":false,"deliveryTimeWindow":{"from":{"hour":6,"minute":0},"to":{"hour":15,"minute":30},"days":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY","SUNDAY"]}}]}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "{authorization}")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Accept", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import http.client
import json
conn = http.client.HTTPSConnection("{baseUrl}")
payload = json.dumps({
"bulkId": "BULK-ID-123-xyz",
"messages": [
{
"scenarioId": "6298AA7707903A4ED680B436929681AD",
"from": "41793026700",
"destinations": [
{
"to": "41793026727"
},
{
"to": "41793026731"
}
],
"notifyUrl": "https://www.example.com/voice/advanced",
"notifyContentType": "application/json",
"callbackData": "DLR callback data",
"validityPeriod": 720,
"sendAt": "2023-10-03T12:21:00.632+0000",
"retry": {
"minPeriod": 1,
"maxPeriod": 5,
"maxCount": 5
},
"record": False,
"deliveryTimeWindow": {
"from": {
"hour": 6,
"minute": 0
},
"to": {
"hour": 15,
"minute": 30
},
"days": [
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY",
"SATURDAY",
"SUNDAY"
]
}
}
]
})
headers = {
'Authorization': '{authorization}',
'Content-Type': 'application/json',
'Accept': 'application/json'
}
conn.request("POST", "/voice/ivr/1/messages", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://{baseUrl}/voice/ivr/1/messages',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"bulkId":"BULK-ID-123-xyz","messages":[{"scenarioId":"6298AA7707903A4ED680B436929681AD","from":"41793026700","destinations":[{"to":"41793026727"},{"to":"41793026731"}],"notifyUrl":"https://www.example.com/voice/advanced","notifyContentType":"application/json","callbackData":"DLR callback data","validityPeriod":720,"sendAt":"2023-10-03T12:21:00.632+0000","retry":{"minPeriod":1,"maxPeriod":5,"maxCount":5},"record":false,"deliveryTimeWindow":{"from":{"hour":6,"minute":0},"to":{"hour":15,"minute":30},"days":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY","SUNDAY"]}}]}',
CURLOPT_HTTPHEADER => array(
'Authorization: {authorization}',
'Content-Type: application/json',
'Accept: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var https = require('follow-redirects').https;
var fs = require('fs');
var options = {
'method': 'POST',
'hostname': '{baseUrl}',
'path': '/voice/ivr/1/messages',
'headers': {
'Authorization': '{authorization}',
'Content-Type': 'application/json',
'Accept': 'application/json'
},
'maxRedirects': 20
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = JSON.stringify({
"bulkId": "BULK-ID-123-xyz",
"messages": [
{
"scenarioId": "6298AA7707903A4ED680B436929681AD",
"from": "41793026700",
"destinations": [
{
"to": "41793026727"
},
{
"to": "41793026731"
}
],
"notifyUrl": "https://www.example.com/voice/advanced",
"notifyContentType": "application/json",
"callbackData": "DLR callback data",
"validityPeriod": 720,
"sendAt": "2023-10-03T12:21:00.632+0000",
"retry": {
"minPeriod": 1,
"maxPeriod": 5,
"maxCount": 5
},
"record": false,
"deliveryTimeWindow": {
"from": {
"hour": 6,
"minute": 0
},
"to": {
"hour": 15,
"minute": 30
},
"days": [
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY",
"SATURDAY",
"SUNDAY"
]
}
}
]
});
req.write(postData);
req.end();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
require "uri"
require "json"
require "net/http"
url = URI("https://{baseUrl}/voice/ivr/1/messages")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "{authorization}"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request.body = JSON.dump({
"bulkId": "BULK-ID-123-xyz",
"messages": [
{
"scenarioId": "6298AA7707903A4ED680B436929681AD",
"from": "41793026700",
"destinations": [
{
"to": "41793026727"
},
{
"to": "41793026731"
}
],
"notifyUrl": "https://www.example.com/voice/advanced",
"notifyContentType": "application/json",
"callbackData": "DLR callback data",
"validityPeriod": 720,
"sendAt": "2023-10-03T12:21:00.632+0000",
"retry": {
"minPeriod": 1,
"maxPeriod": 5,
"maxCount": 5
},
"record": false,
"deliveryTimeWindow": {
"from": {
"hour": 6,
"minute": 0
},
"to": {
"hour": 15,
"minute": 30
},
"days": [
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY",
"SATURDAY",
"SUNDAY"
]
}
}
]
})
response = https.request(request)
puts response.read_body
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65