Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

To access a REST service within IDL you must use the IDLnetUrl object.

 

Reading (GET request)
urlObj = OBJ_NEW('IDLnetUrl')
urlObj->SetProperty, URL_SCHEME = 'http'
urlObj->SetProperty, URL_HOST = 'localhost'
urlObj->SetProperty, URL_PORT = '8001'
urlObj->SetProperty, URL_PATH = 'HMI/sharp_cea_720s_nrt'
urlObj->SetProperty, URL_QUERY = 'start=2016-01-19T00:00:00Z&end=2016-01-19T00:00:00Z&meta=false'
urlObj->SetProperty, HEADERS = 'Content-Type: application/json'
res = urlObj->Get(/string_array, /BUFFER)
resJson = JSON_PARSE(strjoin(res), /TOARRAY, /TOSTRUCT)
Writing (POST request)
data = {time_start: ''2012-01-01T01:01:01Z",data: mydata}
json_data = json_serialize(data,/LOWERCASE)  

urlObj = OBJ_NEW('IDLnetUrl')
urlObj->SetProperty, URL_SCHEME = 'http'
urlObj->SetProperty, URL_HOST = 'localhost'
urlObj->SetProperty, URL_PORT = '8002'
urlObj->SetProperty, URL_PATH = '/region/myProvenance'
urlObj->SetProperty, URL_QUERY = ''
urlObj->SetProperty, HEADERS = 'Content-Type: application/json'
result = urlObj->Put(json_data, /BUFFER, /post)
resJson = JSON_PARSE(strjoin(res), /TOARRAY, /TOSTRUCT)

 

The properties of the IDLnetUrl object are according to the URLs which you get on the http://localhost:8001/ui and http://localhost:8002/uisites.

  • No labels