cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Trouble with passing json in the url in Rest calls

JonathonFowler
12-Amethyst

Trouble with passing json in the url in Rest calls

I currently have a url: http://172.20.100.3/cgi-bin/json.cgi?json={"method": "broadcaston", "params": [1], "id": 10}

 

This is for lighting control, and the json controls what happens with the lights and returns a json when you go to the web page. I am currently using the GetJson snippet and passing in the json.

 

var Mycontent = {
"method" : "broadcastoff",
"params" : "[1]",
"id" : "30"
}

var params = {
url: "http://172.20.100.3/cgi-bin/json.cgi?json=", 
content: Mycontent, 
};


var result = Resources["ContentLoaderFunctions"].GetJSON(params);

All that is being returned is - {"headers":""}

 

Any help with where I'm going wrong would be greatly appreciated. 

 

 

ACCEPTED SOLUTION

Accepted Solutions

The solution is to encapsulate the whole link as a string and use %7b instead of {.

And use %7d instead of }.

 

 

View solution in original post

3 REPLIES 3

What all have you tried so far with the parameters?

Can you try to create the json but 'encapsulated' as a string does that make any difference?

also for the return, instead of doing getjson, try gettext first and see if anything at all is returned.

All I am passing into the parameters is the url, and sometimes the content depending on what I'm trying. 

 

When I try to encapsulate the JSON I got the error -

 

"Error executing service LightTest. Message :: Illegal character in opaque part at index 40: http:172.20.100.3/cgi-bin/json.cgi?json={"method":"broadcastoff","params":"[1]","id":"30"} - See Script Error Log for more details."

 

That is with both getJSON and getText.

The solution is to encapsulate the whole link as a string and use %7b instead of {.

And use %7d instead of }.

 

 

Announcements


Top Tags