Send

Hello. When you run this script is stopped Orthanc. The functions of the "function OnStoredInstance (instanceId, tags, metadata)" sent to another server is successful.

function IncomingHttpRequestFilter(method, uri, ip, username)
  if uri == '/send' then
        ins = ParseJson(RestApiGet('/instances', true))
        SendToModality(ins[1], "TEST")
  end
return true
end

Error:

LuaFunctionCall.cpp:107] [string "line"]:40: bad argument #1 to 'insert' (table expected, got nil)
terminate called after throwing an instance of 'Orthanc::OrthancException'

version 0.9.4

I think the purpose of IncomingHttpRequestFilter is just to perform basic filtering of HTTP request. You are not supposed to perform anything 'smart' there and I'm not sure RestApiGet will work at all.

You should first print the result of RestApiGet (before parsing it to Json) so you already have an idea if it is allowed or not.

You can probably implement your 'send' feature somewhere else:
- in an HTML/javascript page that is served by the ServeFolders plugin
- in a python script or whatever app that was supposed to call your 'send' url

Br

Alain Mazy

I confirm Alain’s answer: “IncomingHttpRequestFilter()” is meant to filter REST requests (e.g. to implement access control list), not to implement routing.

Please carefully read the Orthanc Book about Lua scripting:
https://orthanc.chu.ulg.ac.be/book/users/lua.html

Sébastien-