Mercurial > hg > orthanc
comparison OrthancServer/Resources/Samples/Lua/CallWebService.lua @ 4044:d25f4c0fa160 framework
splitting code into OrthancFramework and OrthancServer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 10 Jun 2020 20:30:34 +0200 |
parents | Resources/Samples/Lua/CallWebService.lua@11f8d72f366f |
children |
comparison
equal
deleted
inserted
replaced
4043:6c6239aec462 | 4044:d25f4c0fa160 |
---|---|
1 -- This sample shows how to call a remote Web service whenever an | |
2 -- instance is received by Orthanc. For this sample to work, you have | |
3 -- to start the "CallWebService.js" script next to this file using | |
4 -- NodeJs. | |
5 | |
6 -- Download and install the JSON module for Lua by Jeffrey Friedl | |
7 -- http://regex.info/blog/lua/json | |
8 | |
9 -- NOTE : Replace "load" by "loadstring" for Lua <= 5.1 | |
10 JSON = (load(HttpGet('http://regex.info/code/JSON.lua'))) () | |
11 | |
12 SetHttpCredentials('alice', 'alicePassword') | |
13 | |
14 function OnStoredInstance(instanceId, tags, metadata) | |
15 -- Build the POST body | |
16 local info = {} | |
17 info['InstanceID'] = instanceId | |
18 info['PatientName'] = tags['PatientName'] | |
19 info['PatientID'] = tags['PatientID'] | |
20 | |
21 -- Send the POST request | |
22 local answer = HttpPost('http://127.0.0.1:8000/', JSON:encode(info)) | |
23 | |
24 -- The answer equals "ERROR" in case of an error | |
25 print('Web service called, answer received: ' .. answer) | |
26 end |