In this blog, I will try to explain you, what is SMS gateway and how to send message using SMS API through X++ code in D365FnO and AX 2012.
An SMS gateway is a technology platform that enables the sending and receiving of SMS (Short Message Service) messages between mobile devices, applications, and computer systems. SMS gateways act as intermediaries between mobile network operators and SMS application providers, allowing them to exchange messages across different networks, countries, and languages. SMS gateways are commonly used by businesses, organizations, and individuals for a variety of purposes, including marketing campaigns, notifications, alerts, and customer service. They can be accessed via APIs, web interfaces, and software applications. To send a SMS using X++ in D365FnO or AX2012, you can follow the following code:
Create a new runnable class.
Copy the below code in the created class.
class SMSGateway
{
public static void main(Args _args)
{
System.Net.WebClient custWebclient;
System.IO.Stream InfoData;
System.IO.StreamReader Streamreader;
System.String URLStr;
Str SMSConfirmID;
str UserName = "ABC";
str MsgSender = "D365FnO";
str ApiPassword ="password123";
str ReceiversStr = "00923227646866";
str MessageBody="Hello, Dear you worked hard for this and you deserve it. - d365fno.com";
str responseStatus = "string";
custWebclient=new System.Net.WebClient();
URLStr = "https://APIProvider/APIManagement/API/RequestAPI?user="+UserName+"&pwd="+ApiPassword+"&sender="+MsgSender+"&reciever="+ReceiversStr+"&msg-data="+ MessageBody+"&response="+responseStatus+"";
InfoData=custWebclient.OpenRead(URLStr);
Streamreader=new System.IO.StreamReader(InfoData);
SMSConfirmID=Streamreader.ReadToEnd();
InfoData.Close();
Streamreader.Close();
info(SMSConfirmID);
}
}