First : Connect to the Extend API
If you aren't sure how to connect to the Core Interface you should first check our Connecting to the Extend API for Core Requests section.
Second : Pick Your Method
If you know how to connect to the Extend API, then you know that you will need to pass in an XML file containing which method you want to run and parameters for that method.
First pick which method you want to run, we have chosen "switchvox.extension.search". Every single request is encased in the parent tag "request" and the method is an attribute of that tag:
<request method="switchvox.extension.search"> </request>
This XML is started, but now we need to add parameters.
Third : Pick Your Parameters
All the documentation on each method is found in this wiki you are reading right now. So after you decided on your method you should find the documentation on that method and look at what parameters that method takes.
Below are all the possible parameters that the method "switchvox.extensions.search".
- See the Constructing Requests page to learn how to use arguments in requests.
|min_extension||optional||string||Minimum extension number.|
|max_extension||optional||integer||Maximum extension number. If both min/max extension is provided, the max must be greater than the min.|
|optional||string||A list of extension types to filter by. See Extension Types for a list of possible values.|
|min_create_date||optional||date||Minimum creation date of extension. Extensions with a create date greater than or equal to this value will be returned. The date should be in the format YYYY-MM-DD HH:MM:SS|
|max_create_date||optional||date||Maximum creation date of extension. Extensions with a create date less than or equal to this value will be returned. The date should be in the format YYYY-MM-DD HH:MM:SS. If both dates are provided, the max must be greater than the min.|
|sort_field||optional||string||number||The field on which to sort the returned extensions. Possible values: number, display, account_id, extension_type and date_created.|
|sort_order||optional||string||ASC||The order in which to sort returned extensions. Possible values: ASC and DESC.|
|items_per_page||optional||integer||50||Number of extensions to return per page.|
|page_number||optional||integer||1||The page number of extensions to return.|
For this example, I want a list of all extensions on my PBX between extension 100 and 200 and I only want extensions that are either an ivr or a call_queue.
So first we need to create the parameters parent tag that will enclose our parameter list:
Now we will add the parameters to the XML:
<request method="switchvox.extensions.search"> <parameters> </parameters> </request>
Next we need to create a tag for each parameter we want to send in enclose the value of each parameter between starting and closing tags:
<request method="switchvox.extensions.search"> <parameters> <min_extension>100</min_extension> <max_extension>200</max_extension> <extension_types> <extension_typ>ivr</extension_typ> <extension_typ>call_queue</extension_typ> </extension_types> </parameters> </request>
You will noticed from the documentation that the extension_types parameter has a sub parameter call extension_type. This denotes that extension_types takes multiple values and extension_types is the parent tag and extension_type is the child tag that will hold the value of each parameter. Mostly, but not always, the parent tag is a plural form of the child tag.
Last : Send Your XML in a Request
After you have your XML file its time to connect to the Extend API and send your file.
What To Do Next
Now that you have learned how to construct a basic API request, you can try a couple of different things.
1. Learn about checking the progress of a long running API.