Mercurial > hg > orthanc
view OrthancServer/Resources/Samples/Lua/CallWebService.lua @ 5531:2bce8d26db5e
added login/pwd to ArchiveStudiesInTimeRange.py
author | Alain Mazy <am@osimis.io> |
---|---|
date | Fri, 09 Feb 2024 09:03:46 +0100 |
parents | d25f4c0fa160 |
children |
line wrap: on
line source
-- This sample shows how to call a remote Web service whenever an -- instance is received by Orthanc. For this sample to work, you have -- to start the "CallWebService.js" script next to this file using -- NodeJs. -- Download and install the JSON module for Lua by Jeffrey Friedl -- http://regex.info/blog/lua/json -- NOTE : Replace "load" by "loadstring" for Lua <= 5.1 JSON = (load(HttpGet('http://regex.info/code/JSON.lua'))) () SetHttpCredentials('alice', 'alicePassword') function OnStoredInstance(instanceId, tags, metadata) -- Build the POST body local info = {} info['InstanceID'] = instanceId info['PatientName'] = tags['PatientName'] info['PatientID'] = tags['PatientID'] -- Send the POST request local answer = HttpPost('http://127.0.0.1:8000/', JSON:encode(info)) -- The answer equals "ERROR" in case of an error print('Web service called, answer received: ' .. answer) end