Get a list of locations
URL: GET /api/v1/locations[?code=<location_code>]
Content: None
Returns: A list of Locations filtered by location_code, if supplied.
Get a location by ID
URL: GET /api/v1/locations/<location_id>
Content: None
Returns: A single Location whose ID is location_id.
Create a location
URL: POST /api/v1/locations
Content: The Location to create.
Returns: The Location created.
Update a location’s information
URL: PUT /api/v1/locations
Content: The Location to update.
Returns: The Location updated.
Delete a location by ID
URL: DELETE /api/v1/location/<location_id>
Content: None
Returns: None
Example Code
public string ReadFirstLocationDescription(string accessToken)
{
string location = string.Empty;
// Create web request to call API (be sure to add access token to request header)
var webRequest = (HttpWebRequest) WebRequest.Create(@"https://app.snapschedule365.com/api/v1/locations");
webRequest.Method = "GET";
webRequest.Accept = @"application/json";
webRequest.Headers.Add("Authorization", "Bearer " + accessToken);
webRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
try
{
using (WebResponse webResponse = webRequest.GetResponse())
{
// If the web response is OK, then read the reply and extract the first location's description
if (( (HttpWebResponse) webResponse).StatusCode == HttpStatusCode.OK)
{
var reader = new StreamReader(webResponse.GetResponseStream());
dynamic locationArray = JsonConvert.DeserializeObject<dynamic>(reader.ReadToEnd());
// If the returned array contains more than one location, extract the first location
if (locationArray.Count > 0)
{
location = locationArray[0].Description;
}
reader.Close();
}
}
}
catch (WebException e)
{
// An error occurred in the call -- handle appropriately
Console.WriteLine(e);
}
return location;
}
function getFirstLocationDescription(accessToken, callback)
{
// URL of API to invoke
var serviceUrl = "https://app.snapschedule365.com/api/v1/locations";
// Create the request
var request = new XMLHttpRequest();
// Build the request
request.open("GET", serviceUrl, true);
request.setRequestHeader("accept", "application/json");
// Add access token to request
request.setRequestHeader("Authorization", "Bearer " + accessToken);
// Set up request status handler
request.onreadystatechange = function()
{
if (request.readyState == 4)
{
if (request.status == 200)
{
var locationArray = JSON.parse(request.responseText);
// If the returned array contains more than one location, extract the first description
if (locationArray.length > 0)
{
callback(locationArray[0].Description);
}
else
{
callback(null);
}
}
else
{
alert("HTTP status: " + request.status + "\n" + request.responseText);
}
}
}
// Send the request
request.send();
}