I am using the RestClient in Unity to make requests to the Microsoft Graph API. So far the RestClient has worked remarkably well and I really enjoy using it.
Recently, I tried doing multiple GET requests to one of the Graph API's endpoint by using the Promise.ThenAll method. In theory, the ThenAll method will chain an enumerable of Promises and will return a new Promise for a collection of resolved results.
I have a method called GetSharePointListColumns that I use to make the GET request:
The childListDict is a Dictionary that in this case will contain 3 entries, basically, I would like to run a GET request for each entry in that Dictionary. The resolved values are all stored in the allRes variable (which, as expected, is an IEnumerable). However, when I debug each of the ResponseHelper in the enumerable, only one of them contains the Data, the other two ResponseHelper will always have null Data. I repeat the debug multiple times and I notice that only one of the ResponseHelper will have a data, and as I have 3 entries in the Dictionary and thus 3 GET requests, the single successful ResponseHelper does not always come from the same entry or GET request, sometimes the single successful ResponseHelper is from the first GET request, sometimes it is the second or the third.
The two ResponseHelper with null Data will also have System.ArgumentNullException: Value cannot be null.
Parameter name: _unity_self exceptions on the Error, Headers, and StatusCode properties of the ResponseHelper
On the other hand, the successful ResponseHelper looks like this:
Just for testing, I tried doing only one request at a time, one for each entry in the dictionary, and all of them can return a ResponseHelper with the correct Data. By doing one request at a time, I mean using Promise.Then followed by only a single GetSharePointListColumns.
Thus, my question is how to actually do multiple requests like this? Is there any part that I did wrongly? Are there any issues with UnityWebRequest?
Thanks a lot!
I am using the RestClient in Unity to make requests to the Microsoft Graph API. So far the RestClient has worked remarkably well and I really enjoy using it.
Recently, I tried doing multiple GET requests to one of the Graph API's endpoint by using the Promise.ThenAll method. In theory, the ThenAll method will chain an enumerable of Promises and will return a new Promise for a collection of resolved results.
I have a method called GetSharePointListColumns that I use to make the GET request:
The GraphGetAPICall is a method that will do the request:
In my main code, I chain multiple GetSharePointListColumns in the following manner:
The childListDict is a Dictionary that in this case will contain 3 entries, basically, I would like to run a GET request for each entry in that Dictionary. The resolved values are all stored in the allRes variable (which, as expected, is an IEnumerable ). However, when I debug each of the ResponseHelper in the enumerable, only one of them contains the Data, the other two ResponseHelper will always have null Data. I repeat the debug multiple times and I notice that only one of the ResponseHelper will have a data, and as I have 3 entries in the Dictionary and thus 3 GET requests, the single successful ResponseHelper does not always come from the same entry or GET request, sometimes the single successful ResponseHelper is from the first GET request, sometimes it is the second or the third.
The two ResponseHelper with null Data will also have System.ArgumentNullException: Value cannot be null. Parameter name: _unity_self exceptions on the Error, Headers, and StatusCode properties of the ResponseHelper
On the other hand, the successful ResponseHelper looks like this:
Just for testing, I tried doing only one request at a time, one for each entry in the dictionary, and all of them can return a ResponseHelper with the correct Data. By doing one request at a time, I mean using Promise.Then followed by only a single GetSharePointListColumns.
Thus, my question is how to actually do multiple requests like this? Is there any part that I did wrongly? Are there any issues with UnityWebRequest? Thanks a lot!