how to add RemoteMoality entery in orthanc.config

Hi,

how to add new remote modality through restAPI without editing/touching orthanc.config file.

https://book.orthanc-server.com/users/rest.html?highlight=remote#sending-resources-to-remote-modalities-through-dicom-c-store

in above rest api, we can only modify remote modality.

is there any possible way-out to add new remote modality through rest API.

Thanks.

Hi,

You can create and update Modalities through the REST Api. The documentation to do that is https://api.orthanc-server.com/#tag/Networking/paths/~1modalities~1{id}/put

Hope that helps.

James

Hi,

I have tried the following command to create new modality.
curl -v -X PUT http://localhost:8042/modalities/sample -d ‘{“AET” : “ORTHANCC”, “Host”: “127.0.0.1”, “Port”: 2002}’

I am getting the following error

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

PUT /modalities/sample HTTP/1.1
Host: localhost:8042
User-Agent: curl/7.55.1
Accept: /
Content-Length: 5
Content-Type: application/x-www-form-urlencoded

  • upload completely sent off: 5 out of 5 bytes
    < HTTP/1.1 400 Bad Request
    < Connection: keep-alive
    < Keep-Alive: timeout=1
    < Content-Length: 196
    <
    {
    “HttpError” : “Bad Request”,
    “HttpStatus” : 400,
    “Message” : “Bad file format”,
    “Method” : “PUT”,
    “OrthancError” : “Bad file format”,
    “OrthancStatus” : 15,
    “Uri” : “/modalities/sample”
    }

I am new to using Orthanc. Please help me to resolve this issue.

Thanks,
Narsimha

Hello,

Your command works properly with Orthanc 1.9.2:

$ curl -v -X PUT http://localhost:8042/modalities/sample -d ‘{“AET” : “ORTHANCC”, “Host”: “127.0.0.1”, “Port”: 2002}’
[…]
< HTTP/1.1 200 OK

Make sure to upgrade your version of Orthanc.

Sébastien-

Thank you for your quick response. I am using the following version

{
   "ApiVersion" : 12,
   "CheckRevisions" : false,
   "DatabaseBackendPlugin" : null,
   "DatabaseVersion" : 6,
   "DicomAet" : "ORTHANC",
   "DicomPort" : 4242,
   "HttpPort" : 8042,
   "IsHttpServerSecure" : true,
   "Name" : "MyOrthanc",
   "PluginsEnabled" : true,
   "StorageAreaPlugin" : null,
   "Version" : "1.9.2"
}

Thanks,
Narsimha

This is the same configuration as mine.

Here is how I start Orthanc:

$ docker run --rm -t -i -p 8042:8042 jodogne/orthanc:1.9.2

And here is the result of your command:

$ curl -u orthanc:orthanc -v -X PUT http://localhost:8042/modalities/sample -d ‘{“AET” : “ORTHANCC”, “Host”: “127.0.0.1”, “Port”: 2002}’

  • Trying 127.0.0.1…
    […]
    < HTTP/1.1 200 OK

As can be seen, everything works properly. You are most probably mixing different versions of Orthanc. In either case, I cannot provide any further support:
https://book.orthanc-server.com/users/support.html#discussing-a-minimal-working-example

Sébastien-

Narsimha, you are damaging the Orthanc bug tracker by reproducing this question on an issue that is by no way not related to your question. I had to disable your account on the bug tracker for this reason.

I have already posted two answers above. Continue to discuss your question on this thread, as explained in the Orthanc Book:
https://book.orthanc-server.com/users/support.html#using-the-bug-tracker

Hi ,

I apologize for the mistake. Please refer the following steps

  1. Un installed Orthanc 1.7.1
  2. Removed C:\Program Files\Orthanc Server folder
  3. Removed C:\Orthanc folder
  4. Re-started the system
  5. Installed 1.9.2
  6. Re-started the system
  7. C:\Users\kunan>curl http://localhost:8042/modalities?expand
    {}
  8. C:\Users\kunan>curl -v -X PUT http://localhost:8042/modalities/sample -d ‘{“AET” : “ORTHANCC”, “Host”: “127.0.0.1”, “Port”: 2002}’
  • Trying ::1…
  • TCP_NODELAY set
  • Trying 127.0.0.1…
  • TCP_NODELAY set
  • Connected to localhost (127.0.0.1) port 8042 (#0)

PUT /modalities/sample HTTP/1.1
Host: localhost:8042
User-Agent: curl/7.55.1
Accept: /
Content-Length: 5
Content-Type: application/x-www-form-urlencoded

  • upload completely sent off: 5 out of 5 bytes
    < HTTP/1.1 400 Bad Request
    < Connection: keep-alive
    < Keep-Alive: timeout=1
    < Content-Length: 196
    <
    {
    “HttpError” : “Bad Request”,
    “HttpStatus” : 400,
    “Message” : “Bad file format”,
    “Method” : “PUT”,
    “OrthancError” : “Bad file format”,
    “OrthancStatus” : 15,
    “Uri” : “/modalities/sample”
    }
  • Connection #0 to host localhost left intact
  • Bad URL, colon is first character
  • Closing connection -1
    curl: (3) Bad URL, colon is first character
  • Rebuilt URL to: ORTHANCC,/
  • Could not resolve host: ORTHANCC,
  • Closing connection 1
    curl: (6) Could not resolve host: ORTHANCC,
  • Rebuilt URL to: Host:/
  • Could not resolve host: Host
  • Closing connection 2
    curl: (6) Could not resolve host: Host
  • Rebuilt URL to: 127.0.0.1,/
  • Connection 0 seems to be dead!
  • Closing connection 0
  • Could not resolve host: 127.0.0.1,
  • Closing connection 3
    curl: (6) Could not resolve host: 127.0.0.1,
  • Rebuilt URL to: Port:/
  • Could not resolve host: Port
  • Closing connection 4
    curl: (6) Could not resolve host: Port
    curl: (3) [globbing] unmatched close brace/bracket in column 5
  1. not able to add new modality using REST API

Thanks,
Narsimha

This is a question related to Windows system administration.

Indeed, the basic Windows prompt doesn’t support single quotes and thus requires escaping:

https://groups.google.com/g/orthanc-users/c/hKIcotiOlnA/m/xC-XGw3SHgAJ

Replace single quotes by double quotes, and prefix double quotes by a backslash character. The following syntax should work (untested, as I don’t use proprietary software):

$ curl -v -X PUT http://localhost:8042/modalities/sample -d “{"AET" : "ORTHANCC", "Host": "127.0.0.1", "Port": 2002}”

Sébastien-

Thank you so much. It is resolved.

Thanks,
Narsimha