Issue36

Title query/retrieve Rest API: /retrieve route shall accept application/json content type
Priority wish Status resolved
Superseder Nosy List admin
Assigned To
Keywords Orthanc Core

Created on 2017-03-13.22:51:42 by admin, last changed by admin.

Messages
msg162 (view) Author: admin Date: 2017-03-13.22:51:42
[BitBucket user: Alain Mazy]
[BitBucket date: 2017-03-13.21:51:42]

Many of these methods only accept the AET as the body of the POST request but fails if the AET is passed as a single string with the content-type set to application/json.  That would be more RestFull to accept json requests as well.

in the integratin tests, we do have

DoPost(_REMOTE, '/queries/%s/answers/0/retrieve' % a, 'ORTHANC')

while we should also accept something like:

DoPost(_REMOTE, '/queries/%s/answers/0/retrieve' % a, 'ORTHANC', 'application/json')


i.e: 
```
static void RetrieveOneAnswer(RestApiPostCall& call)
  {
    size_t index = boost::lexical_cast<size_t>(call.GetUriComponent("index", ""));

    std::string modality;
    call.BodyToString(modality);
```
instead of that, we should have something like:
```
static void RetrieveOneAnswer(RestApiPostCall& call)
  {
    size_t index = boost::lexical_cast<size_t>(call.GetUriComponent("index", ""));
   if (call.ParseJsonRequest(request))
   {
      modality = request.asString()
   }
   else
   {
      std::string modality;
      call.BodyToString(modality);
   }

```
msg163 (view) Author: admin Date: 2017-07-10.21:12:47
[BitBucket user: Alain Mazy]
[BitBucket date: 2017-07-10.19:12:47]

added a test in https://hg.orthanc-server.com/orthanc-tests/changeset/9d09f6f21b60bcc3a2f3623de52ed5d1e7e6ab76

it works already !
History
Date User Action Args
2026-07-29 15:51:19admincreate