Bad Request Answer from Orthanc upon query

I am still hung up on this Issue… Also the examples in the tests are not working,
can anyone provide me with example querys that are accepted by orthanc?

the way I am querying is via curl eg:

curl -v http://localhost:8042/modalities/KAP2/query -X POST -d ‘{“Level”:“Patient”,“CaseSensitive”:False,“Query”:{“PatientName”:“n”}}’

with verbose on, the output is:

Note: Unnecessary use of -X or --request, POST is already inferred.

  • Trying ::1…
  • TCP_NODELAY set
  • Trying 127.0.0.1…
  • TCP_NODELAY set
  • Connected to localhost (127.0.0.1) port 8042 (#0)

POST /modalities/KAP2/query HTTP/1.1
Host: localhost:8042
User-Agent: curl/7.58.0
Accept: /
Content-Length: 61
Content-Type: application/x-www-form-urlencoded

  • upload completely sent off: 61 out of 61 bytes
    < HTTP/1.1 400 Bad Request
    < Content-Length: 0
    <
  • Connection #0 to host localhost left intact

I am really quite lost on the matter, as this is a basic functionality and besides the code of the test repo which does get me nowhere. I cant find documentation on the structure.

Greatful for every bit,

Robert

This works for me, copied from Insomnia REST tool. I’m also using Mirth to do queries and working ok.

curl --request POST
–url http://IPADDRESS:8042/modalities/KAP2/query
–data ‘{“Level”:“Study”,“Query”:{“PatientID”:“P12345”,“StudyDescription”:“Chest”,“PatientName”:“”,“ModalitiesInStudy”:“”}}’

Ok, so by trial and error I found a way to query successfully.
it does not work inline but like:

curl -v -X POST http://localhost:8042/modalities/KAP2/query -d @- << EOF
{“Level” : “Patient”, “Query” : {“PatientID” : “0”}}
EOF

Now I have queries, I can look at them by:

curl -v http://localhost:8042/queries

My next hurdle is: What content does

curl -v http://localhost:8042/modalities/KAP2/retrieve -d @- << EOF
EXPECT HERE?
EOF
?

Hi Brian,
I just saw your answer now, But thanks anyway!!! =)

I figured out how retrieval of the queries works, only that it doesn’t =(

curl -v http://localhost:8042/queries/ebb8e082-94ad-4f5b-9605-ad5c4cf776ac/answers/0/retrieve -d “KAP1”
or
curl -v http://localhost:8042/queries/ebb8e082-94ad-4f5b-9605-ad5c4cf776ac/retrieve -d “KAP1”

both finish with 200 OK but
curl -v http://localhost:8042/studies
is still empty.
and I checked, answers/content was listing the study I wanted.

still desperate for help,

Robert

Here you go, this works for me no problem:

curl --request POST
–url http://ORTHANCADDRESS:8042/queries/6326083f-512f-422f-ad61-8c7cd7643a6e/retrieve
–data ORTHANCAE

Thank you again, after checking all my configurations 5 times and still getting servererrors, I found my problem.
Somehow the machine on which my second Orthanc is running, every now and then (quite often) disconnects from my wifi…
But that is another issue =)

for anyone who might ever have the same struggle as I, here is everything that worked for me(KAP1 was my AET and KAP2 the distant AET):

store sth:
curl -v http://localhost:8042/modalities/KAP2/store -d “9fcadbc3-58807fe5-05a2969e-ab4aafaa-af735eaa”

if all is fine the http says 200 OK and the output is {}

delete sth:
curl -v -X DELETE http://localhost:8042/studies/fc6fbffe-8531efa2-7434a372-09242661-fe012bc6

if it worked http says 200 OK and the output tells you the remaining ancestor

qery stuff:
//this worked in bash but not in windows cmd
curl -v -X POST http://localhost:8042/modalities/KAP2/query -d @- << EOF
{“Level” : “Study”, “Query” : {“PatientID” : “2c*”}}
EOF

returns something like this
{“ID” : “4c39b9e8-3ebc-418e-8041-73531bc924f1”, “Path” : “/queries/4c39b9e8-3ebc-418e-8041-73531bc924f1”}
Bad request is returned if the level- query structure is off and bad fileformat, well, if the format of the data is off

retrieve query:
curl -v -X POST http://localhost:8042/queries/46a139eb-2871-402c-9fa1-3fd2c9d1de29/answers/0/retrieve -d “KAP1”
triggers a C-Move on the query answer with index 0

Thank you for your help,

Robert