Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Parameters lost with JSON RPC interface

I have been battling with a problem about communicating parameters to kscript methods. It seems to me that no parameters are forwarded to kscript. I have succeeded to get a response from my script, yet all the parameters that I am sending back with json stay null all the time.

I was wondering if there is something I have not noticed about sending the requests. I send the POST-request to the following type of url: , with content-type -header application/x-www-form-urlencoded , basic auth that passes and add the parameters. I have tried this request via code, http-master and couple of browser request tools.

My testmethod returns these parameters in json, yet they always stay null. However, when I check if the parameter is null in Kscript (K.params.intparam === null) it returns false. If I return K.params.intparam + 1 it returns 1 (quess Kscript just initializes int as 0).

Does anyone else have this kind of problem? I was reading online and someone said it could be about the protocol version so I tried both http 1.1 and 1.0. I have also tried to put the params to the url (.../testparams.json?intparam=2&another=5), but they are still just null.

I appreciate all ideas and comments!


  • I got this resolved now. The reason for my confusion was twofolded. First, the parameters should be posted as stringdata in form (params[paramname]=paramvalue) and not as formdata as post-method suggests. Also when the param is string-typed, you should not use quotation marks (!).

    I am using Unity and UnityWebRequest for implementing and in case someone else has this confusion, here's a snippet on how to get parameter-stuff done. UnityWebRequests post-initializer can only include formdata (at least in experimental which I'm using), so put initializer is your friend.

    UnityWebRequest www = UnityWebRequest.Put(uri, postdata);
    www.method = UnityWebRequest.kHttpVerbPOST;

  • Glad you figured it out, Lida - and thanks for sharing with the community.

Sign In or Register to comment.