This is a repetition from my two previous questions (Question:1 & Question:2), creating a separate thread as its objective is different.
Thanks @Dmitri, for your quick answers.
After fixing all the code, I am getting Precondition Failed, mostly am expecting because of the content-type
[this is just based on assumption after carefully seeing the error].
Error Detail
HttpResponseProxy{HTTP/1.1 412 Precondition Failed [Date: Thu, 01 Sep 2022 13:39:18 GMT, Content-Type: application/json, Transfer-Encoding: chunked, Connection: keep-alive, Server: openresty, Access-Control-Allow-Origin: *, Access-Control-Expose-Headers: Date, Access-Control-Allow-Headers: X-Acc-Cached,X-File-Name,X-File-Size,X-Requested-With,X-DicomGrid-Client,X-AmbraHealth-part-checksum,X-DicomGrid-Version,X-AmbraHealth-SID,Cache-Control,Content-Encoding,Content-Type,If-None-Match, Access-Control-Request-Headers: X-DicomGrid-Client,X-DicomGrid-Version, Access-Control-Allow-Methods: DELETE,GET,OPTIONS,POST,PATCH,PUT, Vary: Accept-Encoding, Cache-Control: max-age=0, no-cache, Expires: Thu, 01 Sep 2022 13:39:23 GMT] ResponseEntityProxy{[Content-Type: application/json,Chunked: true]}}
Code Base
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.HttpClientBuilder;
def imageFileName = "C:\\Users\\IMAGES\\IMG00001.dcm"
def urlRequest='https://'+${BASE_URL_1}+'/api/v3/storage/namespace/7c762733-009f-4527-81ea-571d1cf6e9d2/image?sid='+vars.get('SIDVALUE')+'&study_uid=1.2.300.0.7230010.3.1.2.2595064201.8112.1216202112026121&image_uid=1.2.840.113704.7.1.0.1356918323635126.1521373008.110'
def postRequest = new HttpPost(urlRequest);
def file = new File(imageFileName);
def builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addBinaryBody("file", file, ContentType.DEFAULT_BINARY, imageFileName);
def entity = builder.build();
postRequest.setEntity(entity);
def response = HttpClientBuilder.create().build().execute(postRequest);
Do I need to add a header with content-type:application/dicom
? Which I already mentioned in the header manager.