Setup a Web API
The easiest way to set up a Web API is to use the REST API channel.
This article describes an alternative way to build your own customized Web API.
This how to shows how to set up a Web API for Auron Omni. With this Web API in place you can use simple HTTP GET or POST requests to send an SMS through Auron Omni.
This is useful in the following situations:
- To send SMS messages from your website or web applications
- When your application runs on a different server
- When you want to send SMS from a Linux system
- If you want to expose an HTTP interface to your customers
- Etc
Overview
By the end of this how to you will be able to send an SMS by going to this URL:
http://
Where
This how to uses ASP Classic in combination with IIS to set up a Web API for Auron Omni. This is one of the easiest ways to quickly set up a working solution because both IIS and ASP are included with Windows.
If you need a Web API with more features or you want to integrate into an existing system, the Auron Omni API works well in PHP, ASP.NET and many other programming languages.
The Auron Omni setup includes working examples for creating your own web interface and Web APIs. You can find these in C:\ProgramData\Auron\Samples\API after installing Auron Omni.
These instructions assume you use a recent Microsoft Server operating system such as Windows Server 2012 or newer. On Windows 10 the IIS steps look slightly different.
We go through the following steps:
- Set up Auron Omni
- Enable IIS
- Set up a new website
- Create Web API
- Test the Web API
- (Optional) Expand and improve
Set up Auron Omni
Follow these steps to set up Auron Omni. Please choose the following configuration options:
- The configuration is either standalone or server
- The database is SQL Server or Microsoft Azure
Next create an SMS channel. This can be an SMPP channel that connects to our test and demonstration gateway.
Enable IIS
The next step is to enable IIS. Click Add roles and features in the Microsoft Windows Server Manager.
Follow the wizard with default settings until you reach the Server Roles page. Check Web Server (IIS). A window appears asking to add the IIS Management Console. Select Add Features and continue.
On the Role Services page, under Application Development, check ASP. A prompt appears to add ISAPI Extensions. Select Add Features and continue.
Set up a new website
Start Internet Information Services (IIS) Manager.
In the left tree view, right click Sites and select Add Website.
Use these settings:
- Name: rest_api
- Physical path: c:\inetpub\rest_api
- Port: 8080
Click OK.
Create the Web API for Auron Omni
We expose three parameters:
- To The recipient of the SMS message
- Body The SMS body
- Channel ID Optional channel ID to use
We use simple form encoding.
To create the API:
- Create a file called sendsms.asp in c:\inetpub\rest_api
- Open it in Notepad and paste the script below
- Save the file
<%
sToAddress = Request("To")
sBody = Request("Body")
sChannel = Request("Channel")
If sToAddress = "" OR sBody = "" Then
Response.Write "Error: Require both 'To' and 'Body' request parameters"
Response.End
End If
Set objMessageDb = CreateObject("AxMmServer.MessageDB")
Set objMessage = objMessageDb.Create("SMS")
objMessage.ToAddress = sToAddress
objMessage.Body = sBody
objMessage.ChannelID = sChannel
objMessageDb.Save objMessage
If objMessageDb.LastError <> 0 Then
Response.Write "Error: " & _
objMessageDB.GetErrorDescription(objMessageDB.LastError)
Response.End
End If
objMessageDb.NotifyStatusUpdate
Response.Write "Success: " & objMessage.ID
%>
This script uses the MessageDB object to create and store a new SMS. After saving the message, NotifyStatusUpdate triggers Auron Omni to send it immediately.
Test the Web API
You can test the Web API directly in a browser.
Use this URL:
http://
If you call it from an application, make sure to URL encode parameters. In JavaScript you can use encodeURI.
Now you know how to set up a Web API for Auron Omni.
Expand and improve
This setup works for most cases, but you can improve it further.
More parameters
You can easily add more fields such as From address, DCS value, batch ID or conversation ID.
Add new request parameters in the TODO sections and map them to the message object.
See the SMS object properties for available fields.
Enable debugging
To show detailed ASP errors:
- Open IIS Manager
- Select your website
- Open ASP
- Enable Send Errors to Browser
Also enable detailed errors:
- Open Error Pages
- Select Edit Feature Settings
- Set to Show detailed errors
Use HTTPS
Create a certificate:
- Open IIS Manager
- Select the server
- Open Server Certificates
- Select Create Self Signed Certificate
- Enter a name and select Web Hosting
Enable HTTPS:
- Open IIS Manager
- Select your website
- Open Bindings
- Add an HTTPS binding
- Select the certificate
If you use a self signed certificate you may see browser warnings.
Enable authentication
Use Basic Authentication with HTTPS.
Install it:
- Open Server Manager
- Add Roles and Features
- Go to Web Server Security
- Enable Basic Authentication
- Install and restart if needed
Enable it in IIS:
- Open IIS Manager
- Select your website
- Open Authentication
- Enable Basic Authentication
- Disable Anonymous Authentication
You now require a server account to access the Web API.







