I have the following curl command which runs through POSTMAN:
curl --location --request GET 'http://myIP:10001/restful-server/fhir/Patient?identifier=2.16.17.710.804.1000.990.1%7C222333069&address-country=CZ&purposeOfUse=TREATMENT' \
--header 'Accept: */*' \
--header 'Accept-Encoding: gzip, deflate' \
--header 'Cache-Control: no-cache' \
--header 'Connection: keep-alive' \
--header 'Content-Type: application/json' \
--header 'Host: myIP:10001' \
--header 'Postman-Token: f1ec5c81-4d6c-4da0-9d91-c30ff72c8b33,11e93bdc-e59c-479a-9141-22818f61e381' \
--header 'User-Agent: PostmanRuntime/7.19.0' \
--header 'X-Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJrLmthcmthbGV0c2lzQGdtYWlsLmNvbSIsImF1ZCI6IndlYiIsInJvbGVzIjoiIiwiaXNzIjoiY2VmY3kuY3MudWN5LmFjLmN5IiwiZXhwIjoxNjEyOTIyODE5LCJpYXQiOjE2MTI5MDg0MTksInVzZXIiOnsib3JndHlwZSI6Im90aGVyIiwiemlwIjpudWxsLCJjb3VudHJ5IjpudWxsLCJmaXJzdG5hbWUiOm51bGwsImFkZHJlc3MiOm51bGwsImNpdHkiOm51bGwsInJvbGVuYW1lIjoiZG9jdG9yIiwidGltZXpvbmUiOm51bGwsInBob25lbnVtYmVyIjpudWxsLCJlbWFpbGFkZHJlc3MiOiJrLmthcmthbGV0c2lzQGdtYWlsLmNvbSIsImxhbmd1YWdlIjoiZW5fR0IiLCJvcmdpZCI6IjEiLCJsYXN0bmFtZSI6bnVsbCwib3JnbmFtZSI6InBvcnRhbCIsInNjcmVlbm5hbWUiOiJkb2N0b3IifSwianRpIjoiMGI3ZjhlNDEtN2NmOC00NWMxLWI4NzYtY2M0OTNkOGJiNGQyIn0.0RUWikdzgeDTXuAoZSgBSpqU5iGL0vYwChVeQAi8grx4f4Cj57F8X6hYh1T' \
--header 'cache-control: no-cache'
I'm trying to call the same from spring-boot:
protected HttpURLConnection prepareConnectionJWT(String serviceUrl, String METHOD, String JWT, String Contentlength)
throws IOException {
URL url = new URL("myIP:10001/restful-server/fhir" + serviceUrl);
System.out.println("\n"+fhirUrl + serviceUrl);
System.out.println("\n"+JWT);
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
// Set the appropriate HTTP parameters.
//httpConn.setRequestProperty("Authorization", "Basic " + this.getBasicAuth());
httpConn.setRequestProperty("Accept", "*/*");
httpConn.setRequestProperty("Accept-Encoding", "gzip, deflate");
httpConn.setRequestProperty("Connection", "keep-alive");
httpConn.setRequestProperty("Χ-Authorization", "Bearer " + JWT);
httpConn.setRequestProperty("Content-Type", "application/json");
httpConn.setRequestProperty("Host", "myIP:10001");
httpConn.setRequestProperty("User-Agent","PostmanRuntime/7.19.0");
httpConn.setRequestProperty("Postman-Token","f1ec5c81-4d6c-4da0-9d91-c30ff72c8b33,11e93bdc-e59c-479a-9141-22818f61e381");
//httpConn.setRequestProperty("Accept", "application/json");
//httpConn.setRequestProperty("Content-Length", Contentlength);
httpConn.setRequestProperty("Cache-Control", "no-cache");
httpConn.setRequestMethod(METHOD);
httpConn.setDoOutput(true);
httpConn.setDoInput(true);
return httpConn;
}
where serviceUrl is /Patient?identifier=2.16.17.710.804.1000.990.1%7C222333069&address-country=CZ&purposeOfUse=TREATMENT
, METHOD is GET and the bearer token is correct.
Using the java code I get error 400 that means the call is not correct.
Any help please?