java.lang.SecurityException: Creating new class groovyx.net.http.HTTPBuilder is not allowed @ line xxx


(Richard Murphy) #1

Trying to use HTTPBuilder() to parse a web page for information.

I’m getting the error, "java.lang.SecurityException: Creating new class groovyx.net.http.HTTPBuilder is not allowed @ line 163 "

I’ve tried new URL() and get the same error.

Anyone know why I can’t open a web page to parse it in SmartThings groovy()?

{code}
def url = "http://data.magnumenergy.com/MW1159/"
def http = new HTTPBuilder(url)
{code}


(Patrick Stuart [@pstuart]) #2

Security reasons use the async_httpget beta.


(Richard Murphy) #3

Thanks!
Using the example code in the documentation for the beta, I’m getting the following error when executing;

java.lang.NullPointerException: Cannot invoke method get() on null object @ line 98

Where line 98 is:
def params = [
uri: ‘https://api.github.com’,
path: ‘/search/code’,
query: [q: “httpGet+repo:SmartThingsCommunity/SmartThingsPublic”],
contentType: ‘application/json’
]


(Richard Murphy) #4

Never mind. It was because I wasn’t including

include ‘asynchttp_v1’


(Patrick Stuart [@pstuart]) #5

Why are you doing an HTTP get against the GitHub repo?


(Richard Murphy) #6

just using the sample code.