Links

Code Snippet Example

Java Script
Node JS
Python
C#
Java
var myHeaders = new Headers();
myHeaders.append("XApiKey", "MY API KEY");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"from": "sender Id",
"body": "My message",
"to": "country code + phone number"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://ypapikey.azurewebsites.net/SMS", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
const axios = require('axios');
let data = JSON.stringify({
"from": "sender Id",
"body": "My message",
"to": "country code + phone number",
"voice": "female",
"lang": "es-CO",
"voiceName": "es-CO-SalomeNeural"
});
let config = {
method: 'post',
url: 'https://ypapikey.azurewebsites.net/Voice',
headers: {
'XApiKey': 'MY API KEY',
'Content-Type': 'application/json'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
import http.client
import json
conn = http.client.HTTPSConnection("https://ypapikey.azurewebsites.net")
payload = json.dumps({
"from": "sender Id",
"body": "My message",
"to": "country code + phone number",
"voice": "female",
"lang": "es-CO",
"voiceName": "es-CO-SalomeNeural"
})
headers = {
'XApiKey': 'MY API KEY',
'Content-Type': 'application/json',
}
conn.request("POST", "/Voice", payload, headers)
res = conn.getresponse()
data = res.read()
var options = new RestClientOptions("https://ypapikey.azurewebsites.net") { MaxTimeout = -1 };
var client = new RestClient(options);
var request = new RestRequest("/Voice", Method.Post);
request.AddHeader("XApiKey", "MY API KEY");
request.AddHeader("Content-Type", "application/json");
var body = @"{
@" ""from"": ""sender Id"",
@" ""body"": ""My message"",
@" ""to"": ""country code + phone number"",
@" ""voiceName""" : ""es-CO-SalomeNeural"",
@" ""lang"" : ""es-CO"",
@" ""voice"" : ""female""
@"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://ypapikey.azurewebsites.net/Voice")
.header("XApiKey", "MY API KEY")
.header("Content-Type", "application/json")
.body("{
"from": "sender Id",
"body": "My message",
"to": "country code + phone number",
"voiceName" : "es-CO-SalomeNeural",
"lang" : "es-CO" || "en-US",
"voice" : "female" || "male"
}")
.asString();
Last modified 3mo ago