OrthancException on OrthancPluginCallPeerApi for "tools/lookup" request

Hi all,

Any idea about this error ?

I call OrthancPluginCallPeerApi method with (see code bellow)

  • a MemoryBuffer for the body answer

  • OrthancPluginHttpMethod_Post method, "

  • “tools/lookup” uri,

  • a peer index

  • the dicom id to find as body

  • the body size

Screenshot from 2022-10-28 17-36-11.png

Hi,
I changed the use from “OrthancPlugins::MemoryBuffer” to “OrthancPluginMemoryBuffer” (and OrthancPluginFreeMemoryBuffer) for my
answerBody variable and the crash didn’t happen anymore.

Is that better to use “OrthancPlugins::MemoryBuffer” method or “OrthancPluginMemoryBuffer”?

Idem for many methods : OrthancPluginRegisterRestCallback or OrthancPlugins::RegisterRestCallback ?

Regards

Audrey

Hello,

If you are developing in C++, it is clearly easier and safer to use the wrapper functions from the “OrthancPlugins” namespace, as they automatically handle memory allocation and error reporting thanks to the RAII design pattern:
https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization

Regards,
Sébastien-