changeset 3478:f93a9c6c00c5

added RestApiPost overload to retrieve a string response
author Alain Mazy <alain@mazy.be>
date Thu, 01 Aug 2019 11:46:01 +0200
parents 3355a2c060c4
children 9b93ec2c53b2
files Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Plugins/Samples/Common/OrthancPluginCppWrapper.h
diffstat 2 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Mon Jul 15 16:48:36 2019 +0200
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Thu Aug 01 11:46:01 2019 +0200
@@ -1249,6 +1249,29 @@
   }
 
 
+  bool RestApiPost(std::string& result,
+                   const std::string& uri,
+                   const void* body,
+                   size_t bodySize,
+                   bool applyPlugins)
+  {
+    MemoryBuffer answer;
+
+    if (!answer.RestApiPost(uri, body, bodySize, applyPlugins))
+    {
+      return false;
+    }
+    else
+    {
+      if (!answer.IsEmpty())
+      {
+        result.assign(answer.GetData(), answer.GetSize());
+      }
+      return true;
+    }
+  }
+
+
   bool RestApiPost(Json::Value& result,
                    const std::string& uri,
                    const void* body,
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Mon Jul 15 16:48:36 2019 +0200
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Thu Aug 01 11:46:01 2019 +0200
@@ -468,6 +468,12 @@
                         const std::map<std::string, std::string>& httpHeaders,
                         bool applyPlugins);
 
+  bool RestApiPost(std::string& result,
+                   const std::string& uri,
+                   const void* body,
+                   size_t bodySize,
+                   bool applyPlugins);
+
   bool RestApiPost(Json::Value& result,
                    const std::string& uri,
                    const void* body,