Hello everyone, thank you for this amazing tool.
I have an Orthanc Server up and running, with an OHIF viewer also running using Docker. I have connection between both also running just fine.
Now I want to send images to the Orthanc Server via the REST API.
I am sending the image using a node.js snippet that
- First downloads the image from a cloud store, then
- Sends the image in binary data (as an ‘arraybuffer’) via a POST call to the Orthanc API.
My orthanc explorer requires a username and password to sign-in, and I have used that to create a basic authorization header, but I keep getting a 401 error from the server.
Below is my code snippet
import axios from “axios”
export default defineComponent({
async run({ steps, $ }) {
function processImage() {
return new Promise(async (resolve, reject) => {
try {
const imageURL = steps.trigger.event.body.imageURL;
const response = await axios.get(imageURL, {responseType: "arraybuffer"});
const imageData = response.data;
const username = <my username>;
const password = <my password>;
const token = Buffer.from(`${username}:${password}`).toString('base64');
const orthancURL = "<my server host and port>/instances";
const headers = {
"Content-Type": "application/dicom",
"Authorization": `Basic ${token}`,
"Content-Disposition": "attachment; filename=image.dcm"
};
const config = {
headers: headers,
data: imageData
};
const response3 = await axios.post(orthancURL, imageData, config);
resolve(response3.data);
} catch (error) {
reject(error);
}
});
}
const result = await processImage();
return result;
},
})
Is there something I am doing wrong? Any help will be much appreciated