diff --git a/Assets/AppServices/README.md b/Assets/AppServices/README.md
index 00f4791..727e076 100644
--- a/Assets/AppServices/README.md
+++ b/Assets/AppServices/README.md
@@ -18,7 +18,7 @@ For detailed instructions read my developer blog on [how to setup Azure App Serv
API | Description
--- | -----------
Login | Client-directed login using access token.
-InvokeApi | Get custom API
+InvokeApi | Invoke custom API (Easy API) using GET, POST, PUT, PATCH or DELETE
### MobileServiceTable
API | Description
diff --git a/Assets/AppServices/client/IAzureMobileServiceClient.cs b/Assets/AppServices/client/IAzureMobileServiceClient.cs
index c110912..bcceb4a 100644
--- a/Assets/AppServices/client/IAzureMobileServiceClient.cs
+++ b/Assets/AppServices/client/IAzureMobileServiceClient.cs
@@ -22,8 +22,18 @@ public interface IAzureMobileServiceClient
//void Login(MobileServiceAuthenticationProvider provider);
///
- /// TODO: Custom API
+ /// Invokes a custom API using GET HTTP method
///
void InvokeApi(string apiName, Action> callback = null) where T : new();
+
+ ///
+ /// Invokes a custom API for HTTP Methods: GET, POST, PUT, PATCH, DELETE
+ ///
+ void InvokeApi(string apiName, Method httpMethod, Action> callback = null) where T : new();
+
+ ///
+ /// Invokes a custom API with body object
+ ///
+ void InvokeApi (string apiName, Method httpMethod, T body, Action> callback = null) where T : new();
}
}
\ No newline at end of file
diff --git a/Assets/AppServices/client/MobileServiceClient.cs b/Assets/AppServices/client/MobileServiceClient.cs
index b24fcc6..8c07046 100644
--- a/Assets/AppServices/client/MobileServiceClient.cs
+++ b/Assets/AppServices/client/MobileServiceClient.cs
@@ -97,16 +97,36 @@ public void Login(MobileServiceAuthenticationProvider provider)
//*/
///
- /// TODO: Implement custom API (using GET request)
+ /// GET custom API
///
public void InvokeApi(string apiName, Action> callback = null) where T : new()
{
- string uri = URI_API + apiName;
- ZumoRequest request = new ZumoRequest(this, uri, Method.GET);
- Debug.Log( "Custom API Request Uri: " + uri );
- this.ExecuteAsync(request, callback);
+ InvokeApi (apiName, Method.GET, callback);
}
+ ///
+ /// Invokes custom API for HTTP Methods: GET, POST, PUT, PATCH, DELETE
+ ///
+ public void InvokeApi(string apiName, Method httpMethod, Action> callback = null) where T : new()
+ {
+ string uri = URI_API + apiName;
+ ZumoRequest request = new ZumoRequest(this, uri, httpMethod);
+ Debug.Log( httpMethod.ToString() + " custom API Request Uri: " + uri );
+ this.ExecuteAsync(request, callback);
+ }
+
+ ///
+ /// Invokes custom API with body
+ ///
+ public void InvokeApi(string apiName, Method httpMethod, T body, Action> callback = null) where T : new()
+ {
+ string uri = URI_API + apiName;
+ ZumoRequest request = new ZumoRequest(this, uri, httpMethod);
+ request.AddBody (body);
+ Debug.Log( httpMethod.ToString() + " custom API Request Uri: " + uri );
+ this.ExecuteAsync(request, callback);
+ }
+
///
/// When you copy the URL is is 'http' by default, but its preferable to use 'https'
///
diff --git a/Assets/Scripts/HighscoresDemo.cs b/Assets/Scripts/HighscoresDemo.cs
index 99bc4dc..b649a3e 100644
--- a/Assets/Scripts/HighscoresDemo.cs
+++ b/Assets/Scripts/HighscoresDemo.cs
@@ -245,15 +245,15 @@ public void GetAllHighscores()
private void GetPageHighscores()
{
- CustomQuery query = new CustomQuery ("", "score desc", _noPageResults, _skip, "id,username,score"); //CustomQuery.OrderBy ("score desc");
- _table.Query>(query, OnReadNestedResultsCompleted); //Query(query);
+ CustomQuery query = new CustomQuery ("", "score desc", _noPageResults, _skip, "id,username,score");
+ _table.Query>(query, OnReadNestedResultsCompleted);
}
public void GetTopHighscores()
{
DateTime today = DateTime.Today;
string day = today.ToString("s");
- string filter = string.Format("createdAt gt '{0}Z'", day); //string.Format("score gt {0}", 999);
+ string filter = string.Format("createdAt gt '{0}Z'", day);
Debug.Log ("filter:" + filter);
string orderBy = "score desc";
CustomQuery query = new CustomQuery(filter,orderBy,10);
@@ -263,7 +263,7 @@ public void GetTopHighscores()
public void GetUsernameHighscore()
{
Highscore score = GetScore ();
- string filter = string.Format("username eq '{0}'", score.username); // string.Format("startswith(username,'{0}')", score.username);
+ string filter = string.Format("username eq '{0}'", score.username);
string orderBy = "score desc";
CustomQuery query = new CustomQuery(filter,orderBy);
Query(query);
@@ -308,12 +308,12 @@ private void OnLookupCompleted(IRestResponse response)
///
public void Hello()
{
- _client.InvokeApi("hello", OnCustomApiCompleted);
+ _client.InvokeApi("hello", Method.GET, OnCustomApiCompleted);
}
public void GenerateScores()
{
- _client.InvokeApi("GenerateScores", OnCustomApiCompleted);
+ _client.InvokeApi("GenerateScores", Method.POST, OnCustomApiCompleted);
}
private void OnCustomApiCompleted(IRestResponse response)
@@ -472,7 +472,7 @@ public int GetNumberOfRowsForTableView(TableView tableView)
public float GetHeightForRowInTableView(TableView tableView, int row)
{
- return (_cellPrefab.transform as RectTransform).rect.height; //50.0f;
+ return (_cellPrefab.transform as RectTransform).rect.height;
}
public TableViewCell GetCellForRowInTableView(TableView tableView, int row)
diff --git a/README.md b/README.md
index 916f03a..12072d0 100644
--- a/README.md
+++ b/README.md
@@ -51,8 +51,8 @@ table.insert(function (context) {
## Setup Azure App Services custom APIs with **Easy APIs**
With [Azure App Services](https://portal.azure.com/) you can create custom APIs using **Easy APIs**.
-1. Create a 'hello' api to say hello! (Example Easy API message script below)
-2. Create a 'GenerateScores' api to generate 10 random scores. (Example Easy API query script below)
+1. Create a 'hello' api (using "get" method) to say hello! (Example Easy API message script below)
+2. Create a 'GenerateScores' api (using "post" method) to generate 10 random scores. (Example Easy API query script below)
#### Easy API 'hello' script (*api/hello.js*)
```node
@@ -67,7 +67,7 @@ module.exports = {
```node
var util = require('util');
module.exports = {
- "get": function (req, res, next) {
+ "post": function (req, res, next) {
var insert = "INSERT INTO Highscores (username,score) VALUES ";
var i = 10;
while (i--) {