Unity3dAzure / AppServicesDemo

Azure App Services demos for Unity
https://www.deadlyfingers.net/tutorial/azure-app-services-for-unity3d
MIT License
27 stars 13 forks source link

Sending and using variables in an easy api call #42

Open Reddevildragg opened 6 years ago

Reddevildragg commented 6 years ago

Hi Im just working with the azure code here, and wondering if there is an example anywhere of sending custom data to the easy api system and then being able to access that on the server. So far i have been trying to use /// <summary> /// Invokes custom API with body (of type B) and returning response (of type T) /// </summary> public IEnumerator InvokeApi<B, T>(string apiName, Method httpMethod, B body, Action<IRestResponse<T>> callback = null) where T : new() { string url = ApiUrl(apiName); Debug.Log(httpMethod.ToString() + " custom API Request Url: " + url); ZumoRequest request = new ZumoRequest(url, httpMethod, true, User); request.AddBody<B>(body); yield return request.Request.Send(); request.ParseJson<T>(callback); }

but appear to not receive the body under the req in the get request on easy api. is there an example of something i can do here, any help would be greatly appreciated. Thanks

deadlyfingers commented 6 years ago

@Reddevildragg so in the case you mention that is for a custom API which is for EASY APIs. In this case you can send up a body as one type of object B, and receive the same type or a different object type T in the response. The closest example of EASY APIs (using the one object type) is: https://github.com/Unity3dAzure/AppServicesDemo/blob/master/Assets/Scripts/HighscoresDemo.cs#L317 Does that help? Or would it help better to add this functionality to the demo?

Reddevildragg commented 6 years ago

Hi there. I was able to figure it out in the end with a bit of trial and error. It may be nice to have an example just incase people come across this in the future. Thanks for the response.