- 
                Notifications
    You must be signed in to change notification settings 
- Fork 14
Sample usage
        David Douglas edited this page Nov 7, 2017 
        ·
        2 revisions
      
    Sample usage showing how to call "hello" Azure Function API:
using RESTClient;
using System;
public class RESTDemo : MonoBehaviour {
	// Use this for initialization
	void Start () {
		StartCoroutine( Get(GetCompleted) );
	}
	private IEnumerator Get(Action<IRestResponse<string>> callback = null) {
		RestRequest request = new RestRequest("https://***.azurewebsites.net/api/hello", Method.POST);
		request.AddHeader("Content-Type", "application/json");
		request.AddQueryParam("code", "***");
		request.AddBody("{\"name\": \"unity\"}");
		yield return request.Request.Send();
		request.GetText(callback);
	}
	private void GetCompleted(IRestResponse<string> response) {
		if (response.IsError) {
			Debug.LogError("Request error:" + response.StatusCode);
			return;
		}
		Debug.Log("Completed:" + response.Content);
	}
}