anton6984647
Posts: 0
Joined: Mon Jul 14, 2014 3:53 pm

ScriptCall Server Code Response

I'm calling a script from another script server-side

call:
var res = ScriptCall.call("123", {"user_id":33}, "body text", "text/plain");

(this script 123 gives the response {"urlpic":"test"} when tested independently)

What code do I use to get this in the response of the original script?

Right now I'm trying to use
otheruserpic=res.body;
but this gives an incorrect output to what I want: {"otheruserpicurl":"{\"urlpic\"":\""test\""}""}
I just need {""otheruserpicurl"":""test""}"

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

ScriptCall Server Code Response

Hi Anton,

Please use the following code:preotheruserpic = res.object().urlpic;/preInstead of:preotheruserpic=res.body;/pre

anton6984647
Posts: 0
Joined: Mon Jul 14, 2014 3:53 pm

ScriptCall Server Code Response

ok, I have this

var res = ScriptCall.call("123", {"user_id":seconduserclient, "SSTokenclt":SSTokenclient}, "body text", "text/plain");
var otheruserpic=res.object().urlpic;

this gives "message: Object #div class="video-container"object has no method 'object'
code: undefined" Any suggestions?/object

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

ScriptCall Server Code Response

Hello Anton,

A string comes to res.body. If you need to get an object, use JSON.parse
prevar obj = JSON.parse(res.body);/pre
Now you can get the value urlpic from the object obj
preobj.urlpic/pre

anton6984647
Posts: 0
Joined: Mon Jul 14, 2014 3:53 pm

ScriptCall Server Code Response

Great! Thanks for the explanation as well.

girish
Posts: 0
Joined: Sat Aug 30, 2014 12:15 pm

ScriptCall Server Code Response

How do i get the id or alias name of a server code script?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

ScriptCall Server Code Response

Hi Girish,

You can get script id from url to this script.

See details: http://prntscr.com/52h6rh/direct

Regards.

girish
Posts: 0
Joined: Sat Aug 30, 2014 12:15 pm

ScriptCall Server Code Response

Thanks. This is also available under "rest information". Now my question is, will the request header be passed as well to the called script? It doesn't work for me when I call a script, say A, that contains the line request.user._id.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

ScriptCall Server Code Response

Hi Girish,

Unfortunatly there is no ability to pass headers.

If you need it you can use XHR.send instead of "ScriptCall.call".

Regards.

Return to “Issues”