Sign In Register

How can we help you today?

Start a new topic

SparkRequests Usage


     I wrote some cloud code for ChallengeEvent. and I create a request in another cloud script using SparkRequests.

I'm facing two issues here.

1. As I couldn't find documentation on SparkRequests, I tried few ways.

var challengeEventRequest = new SparkRequests.LogCha  

        var challengeEventRequest = new SparkRequests.LogChallengeEventRequest();
        challengeEventRequest.challengeInstanceId = instanceId;
        challengeEventRequest.eventKey = eventName;
        if(ASYNC_CHALLENGE_EVENT_ATTRIBUTE_KEY === eventAttributeName)
            challengeEventRequest.SCORES_PER_TURN_ATTRIBUTE = JSON.stringify(scriptInfo);

        //Send the request.
        var response = challengeEventRequest.Send();


            In above code, I saved my challenge event keys in a module and fetching the values from there. But I'm getting a runtime error because Its not taking the expected key for challenge event attribute.

     How can i write some thing like this.

     challengeEventRequest.eventAttributeName= JSON.stringify(scriptInfo);

instead of 

challengeEventRequest.SCORES_PER_TURN_ATTRIBUTE = JSON.stringify(scriptInfo);

The later statement actually breaking my code's modularity. Please let me know if any possible solution in this aspect.

2. SparkRequests call is not going through the cloud code for request and responses I created. This I see is very much important for issuing requests in cloud code. Im sure I might be missing something in this aspect. Please help me out.



Best Answer

Answer for first question SparkRequests Doc

Second problem I mentioned in above question was answered here - Cloud Code execution not possible from cloud scripts to avoid infinite loop.

I wish GameSparks answers if any solutions available for 1st point.


Answer for first question SparkRequests Doc