public void Get() { // We can add default request headers for all requests RestClient.DefaultRequestHeaders["Authorization"] = "Bearer ..."; RequestHelper requestOptions = null; RestClient.GetArray <Post>(basePath + "/posts").Then(res => { this.LogMessage("Posts", JsonHelper.ArrayToJsonString <Post>(res, true)); return(RestClient.GetArray <Todo>(basePath + "/todos")); }).Then(res => { this.LogMessage("Todos", JsonHelper.ArrayToJsonString <Todo>(res, true)); return(RestClient.GetArray <User>(basePath + "/users")); }).Then(res => { this.LogMessage("Users", JsonHelper.ArrayToJsonString <User>(res, true)); // We can add specific options and override default headers for a request requestOptions = new RequestHelper { Uri = basePath + "/photos", Headers = new Dictionary <string, string> { { "Authorization", "Other token..." } }, EnableDebug = true }; return(RestClient.GetArray <Photo>(requestOptions)); }).Then(res => { this.LogMessage("Header", requestOptions.GetHeader("Authorization")); // And later we can clean the default headers for all requests RestClient.CleanDefaultHeaders(); }).Catch(err => this.LogMessage("Error", err.Message)); }
public void Get() { RestClient.DefaultRequestHeaders["Authorization"] = "Bearer ..."; RequestHelper requestOptions = null; RestClient.GetArray <Post>(basePath + "/posts").Then(res => { LogMessage("Posts", JsonHelper.ArrayToJsonString <Post>(res, true)); return(RestClient.GetArray <Todo>(basePath + "/todos")); }).Then(res => { LogMessage("Todos", JsonHelper.ArrayToJsonString <Todo>(res, true)); return(RestClient.GetArray <User>(basePath + "/users")); }).Then(res => { LogMessage("Users", JsonHelper.ArrayToJsonString <User>(res, true)); requestOptions = new RequestHelper { Uri = basePath + "/photos", Headers = new Dictionary <string, string> { { "Authorization", "Other token..." } }, EnableDebug = true }; return(RestClient.GetArray <Photo>(requestOptions)); }).Then(res => { LogMessage("Header", requestOptions.GetHeader("Authorization")); RestClient.ClearDefaultHeaders(); }).Catch(err => LogMessage("Error", err.Message)); }
public void Get() { // We can add default request headers for all requests RestClient.DefaultRequestHeaders["Authorization"] = "Bearer ..."; RequestHelper requestOptions; RestClient.GetArray <Post>(basePath + "/posts").Then(res => { EditorUtility.DisplayDialog("Posts", JsonHelper.ArrayToJsonString <Post>(res, true), "Ok"); return(RestClient.GetArray <Todo>(basePath + "/todos")); }).Then(res => { EditorUtility.DisplayDialog("Todos", JsonHelper.ArrayToJsonString <Todo>(res, true), "Ok"); return(RestClient.GetArray <User>(basePath + "/users")); }).Then(res => { EditorUtility.DisplayDialog("Users", JsonHelper.ArrayToJsonString <User>(res, true), "Ok"); // We can add specific options and override default headers for a request requestOptions = new RequestHelper { url = basePath + "/photos", headers = new Dictionary <string, string> { { "Authorization", "Other token..." } } }; return(RestClient.GetArray <Photo>(requestOptions)); }).Then(res => { EditorUtility.DisplayDialog("Header", requestOptions.GetHeader("Authorization"), "Ok"); // And later we can clean the default headers for all requests RestClient.CleanDefaultHeaders(); }).Catch(err => EditorUtility.DisplayDialog("Error", err.Message, "Ok")); }
public void Greet() { RestClient.DefaultRequestParams["lang"] = "en"; currentRequest = new RequestHelper { Uri = basePath + "/webhooks/rest/webhook", Params = new Dictionary <string, string> { { "param1", "value 1" }, { "param2", "value 2" } }, Body = new RasaMessage { sender = "samlet", message = "hello" }, EnableDebug = true }; RestClient.PostArray <RasaResponse>(currentRequest) .Then(res => { // And later we can clear the default query string params for all requests RestClient.ClearDefaultParams(); // this.LogMessage("Success", JsonUtility.ToJson(res, true)); this.LogMessage("Success", JsonHelper.ArrayToJsonString <RasaResponse>(res, true)); }) .Catch(err => this.LogMessage("Error", err.Message)); }
public void getArray <T>(RequestHelper options, Action <T[]> ret) { RestClient.GetArray <T>(options).Then(res => { this.LogMessage("Posts", JsonHelper.ArrayToJsonString <T>(res)); ret(res); }).Catch(err => this.LogMessage("Error", err.Message)); }
public void Instruct(string sents) { RestClient.DefaultRequestParams["lang"] = "en"; currentRequest = new RequestHelper { Uri = basePath + "/info/behave/en", Params = new Dictionary <string, string> { { "param1", "value 1" }, { "param2", "value 2" } }, Body = new InstructMessage { sents = sents }, EnableDebug = true }; RestClient.PostArray <IntentResponse>(currentRequest) .Then(res => { // And later we can clear the default query string params for all requests RestClient.ClearDefaultParams(); // this.LogMessage("Success", JsonUtility.ToJson(res, true)); this.LogMessage("Success", JsonHelper.ArrayToJsonString <IntentResponse>(res, true)); this.ProcessMessages(res); }) .Catch(err => this.LogMessage("Error", err.Message)); }
//Get Method public void GetAllClients() { string uri = "http://localhost:3001/api/ride-offers"; RestClient.GetArray <test>(uri).Then(res => { Debug.Log("RES: " + res); string t = JsonHelper.ArrayToJsonString <test>(res, true); Debug.Log("CLIENT NAME :" + res[0].clientName); Debug.Log("SSS: " + t); }); }
public void GetCharacters(int userid) { var items = characters.Where(x => x.userid == userid).ToArray(); var statusCode = 200; var json = "[]"; if (items.Length != 0) { json = JsonHelper.ArrayToJsonString(items); } GetCharactersCallback?.Invoke(statusCode, json); }
public void Get() { // We can add default request headers for all requests RestClient.DefaultRequestHeaders["Authorization"] = "Bearer ..."; RestClient.Get("http://localhost:8080/api/v1/server/opcuatestserver/namespace/2/identifier/4294967294").Then(res => { EditorUtility.DisplayDialog("Response", res.Text, "Ok"); }); //RestClient.Get("http://localhost:8080/api/v1/server/opcuatestserver/namespace/2/identifier/Demo.Static.Scalar.String").Then(res => { // EditorUtility.DisplayDialog("Response", res.Text, "Ok"); //}); var testData = new Dictionary <string, string>() { { "variableData", "Test write" }, }; RestClient.Put("http://localhost:8080/api/v1/server/opcuatestserver/namespace/2/identifier/Demo.Static.Scalar.String", JsonConvert.SerializeObject(testData)).Then(res => { EditorUtility.DisplayDialog("Status", res.StatusCode.ToString(), "Ok"); }); RequestHelper requestOptions = null; RestClient.GetArray <Post>(basePath + "/posts").Then(res => { this.LogMessage("Posts", JsonHelper.ArrayToJsonString <Post>(res, true)); return(RestClient.GetArray <Todo>(basePath + "/todos")); }).Then(res => { this.LogMessage("Todos", JsonHelper.ArrayToJsonString <Todo>(res, true)); return(RestClient.GetArray <User>(basePath + "/users")); }).Then(res => { this.LogMessage("Users", JsonHelper.ArrayToJsonString <User>(res, true)); // We can add specific options and override default headers for a request requestOptions = new RequestHelper { Uri = basePath + "/photos", Headers = new Dictionary <string, string> { { "Authorization", "Other token..." } }, EnableDebug = true }; return(RestClient.GetArray <Photo>(requestOptions)); }).Then(res => { this.LogMessage("Header", requestOptions.GetHeader("Authorization")); // And later we can clear the default headers for all requests RestClient.ClearDefaultHeaders(); }).Catch(err => this.LogMessage("Error", err.Message)); }
// Use this for initialization void Start() { UriBuilder ub = new UriBuilder(new Uri(url)) { Path = "Thaihistory/api/users" }; /*RestClient.Get(ub.Uri.AbsoluteUri).Then(response => * { * var test = response.text; * });*/ RestClient.GetArray <User>(ub.Uri.AbsoluteUri).Then(allUsers => { EditorUtility.DisplayDialog("JSON Array", JsonHelper.ArrayToJsonString(allUsers, true), "Ok"); }); }