- Home /
WAK - WebAPIKit - on-complete error when retrieving JSON
I am using WAK (Web API Kit) to retrieve JSON from my server but I have a problem with on-complete action and no matter what I do, I can't figure out a way to solve it. Any help would be appreciated.
This is the error I get:
{ERR} [184044FE]'on-complete' User Action invocation failed hard with error: Exception has been thrown by the target of an invocation.
UnityEngine.Debug:LogError(Object)
hg.ApiWebKit.Configuration:Log(String, LogSeverity) (at Assets/WAK.core/WAK/CORE/Configuration.cs:175)
hg.ApiWebKit.Configuration:LogInternal(String, String, LogSeverity) (at Assets/WAK.core/WAK/CORE/Configuration.cs:198)
hg.ApiWebKit.core.http.HttpOperation:Log(String, LogSeverity) (at Assets/WAK.core/WAK/CORE/core/http/HttpOperation.cs:29)
hg.ApiWebKit.core.http.HttpOperation:tryUserAction(String, Object[]) (at Assets/WAK.core/WAK/CORE/core/http/HttpOperation.cs:242)
hg.ApiWebKit.core.http.HttpOperation:<SendRequest>m__4(HttpResponse) (at Assets/WAK.core/WAK/CORE/core/http/HttpOperation.cs:213)
hg.ApiWebKit.core.http.HttpAbstractProvider:BehaviorComplete() (at Assets/WAK.core/WAK/CORE/core/http/HttpAbstractProvider.cs:128)
hg.ApiWebKit.providers.<sendImplementation>c__IteratorB:MoveNext() (at Assets/WAK.core/WAK/providers/HttpWWWClient.cs:59)
And this is the code:
PlayerManager.cs
This is where the log complains on the line TextCash.text = operation.response.Cash.ToString(); What I don't understand is that if I do a print log of operation.response.Cash it works without problems and I use similar code in other classes and I have no problem.
namespace hg.ApiWebKit.cyclingsim.client
{
public class PlayerManager : MonoBehaviour
{
public GameObject CurrenciesGameObj; //this is the gameObject that holds the currencies text components inside
public GameObject UserProfileGameObj; //this is the gameObject that holds the user profile info like Level and Energy text components inside
public Slider NRJSlider;
public Text TextPlayerLevel;
public Text TextEnergyTimer;
public Text TextXPToNextLevel;
public Text TextTrainingPoints;
public Text TextGems;
public Text TextCash;
public IEnumerator SqlLoad(string playerid)
{
yield return new WaitForSeconds(2.0f);
new hg.ApiWebKit.cyclingsim.operations.LoadPlayer()
{
playerid = playerid
}.Send(null, null, onComplete);
yield break;
}
private void onComplete(LoadPlayer operation, hg.ApiWebKit.core.http.HttpResponse response)
{
// Update currencies
TextCash.text = operation.response.Cash.ToString();
...
}
LoadPlayer.cs
namespace hg.ApiWebKit.cyclingsim.operations
{
[HttpGET]
[HttpPath("mytestproj", "/v1/players/{$playerid}")]
[HttpProvider(typeof(hg.ApiWebKit.providers.HttpWWWClient))]
[HttpAccept("application/json")]
[HttpContentType("application/x-www-form-urlencoded; charset=UTF-8")]
[HttpRequestHeader(
VariableName = "myAuthHeaderName",
VariableValue = "myAuthHeaderValue")]//,
//Converter= typeof(hg.ApiWebKit.converters.BasicAuthEncode))]
public class LoadPlayer : HttpOperation
{
[HttpUriSegment("playerid")]
public string playerid;
[HttpResponseJsonBody] // expected JSON object response
public models.Player response;
}
}
Any ideas ?
Thanks in advance
I would have to see your Player model. A hard failure like that usually leads to some issue in the user code.
Answer by Chris-HG · Oct 08, 2015 at 12:46 PM
Hi @aroda. I just found this post. If you still have a problem please submit @ http://haptixgames.com/forum/viewforum.php?f=13.
/chris
Your answer