Is public FHIR test server support PATCH Operation

887 views
Skip to first unread message

Ram Mittala

unread,
Jul 7, 2017, 7:29:35 PM7/7/17
to HAPI FHIR
Hi ,

I am trying to test the update the only few elements in Patient resource using PATCH Operation.


There is no response for PATCH operation from TEST Server?


Regards
Ram Mittala

James Agnew

unread,
Jul 8, 2017, 10:09:37 AM7/8/17
to Ram Mittala, HAPI FHIR
Hi Ram,

FHIR defines three formats for patch (see here: http://hl7.org/fhir/http.html#patch )

HAPI JPA supports the XML Patch and JSON Patch methods, but does not yet support the FHIR Patch method.

Are you using one of the first two methods? If so, could you share the patch payload you're using?

Cheers,
James

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/51c004a4-c12f-49d9-b57d-3e6ee698261d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ram Mittala

unread,
Jul 10, 2017, 5:15:09 PM7/10/17
to HAPI FHIR
Hi James,

Here is the sample Patient Resource and PATH request.


Body :

[
  { "op": "replace", "path": "/gender", "value": "male" }
]


Header :
[{"key":"Content-Type","value":"application/json-patch+json","description":""}]


Response :

No response from server
There was an error connecting to http://fhirtest.uhn.ca/baseDstu3/Patient/70285

James Agnew

unread,
Jul 11, 2017, 6:01:43 PM7/11/17
to Ram Mittala, HAPI FHIR
Hi Ram,

You know what, you're right! The HAPI FHIR JPA server supports it, but somewhere along the way it looks like it got configured to block the HTTP Patch verb from being allowed through.

Will redeploy this later tonight with a fix.

Cheers,
James


--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.

James Agnew

unread,
Jul 12, 2017, 11:32:16 AM7/12/17
to Ram Mittala, HAPI FHIR
Hi Ram,

The server has now been deployed with PATCH support working once again. The following curl request succeeds for me at least:

curl -X PATCH -H "Content-Type: application/json-patch+json" --data '[
                 { "op": "replace", "path": "/gender", "value": "male" }

Cheers,
James

Ram Mittala

unread,
Jul 12, 2017, 12:05:56 PM7/12/17
to HAPI FHIR, seetharam...@gmail.com
Thanks James for the update.

I just checkout the latest code and I see the fix.

However, I have tried the same request using Postman/curl and I am still having the same issue.

Attached the screenshot.

Any suggestion?

Regards
Ram Mittala
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.

To post to this group, send email to hapi...@googlegroups.com.
PatientPatch_2.png
Patient_Patch.png

Ram Mittala

unread,
Jul 12, 2017, 12:32:04 PM7/12/17
to HAPI FHIR, seetharam...@gmail.com
And one more thing I noticed that,

If I try the same request to https url then I got the following error.


Resposne from server :
Invalid CORS request

Connection →keep-alive
Content-Length →20
Date →Wed, 12 Jul 2017 16:28:44 GMT
Server →nginx/1.10.0 (Ubuntu)

Regards
Ram

James Agnew

unread,
Jul 12, 2017, 2:01:09 PM7/12/17
to Ram Mittala, HAPI FHIR
Hi Ram,

Can you try again? It looks like Postman sends CORS headers in its requests, and the server CORS filter wasn't allowing PATCH with CORS.

Cheers,
James

To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.

To post to this group, send email to hapi...@googlegroups.com.

Ram Mittala

unread,
Jul 12, 2017, 2:18:45 PM7/12/17
to HAPI FHIR, seetharam...@gmail.com

Thanks, James,

It worked with HTTPS URL now.

Any idea, why it is still now working with HTTP url ?

When are you planning to release these changes (i.ev 2.6 version )?

Regards
Ram

James Agnew

unread,
Jul 12, 2017, 3:02:36 PM7/12/17
to Ram Mittala, HAPI FHIR

To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.

To post to this group, send email to hapi...@googlegroups.com.

Ram Mittala

unread,
Jul 12, 2017, 5:42:23 PM7/12/17
to HAPI FHIR, seetharam...@gmail.com
James,


Do I need to make any changes in hapi-fhir-jpaserver-base to make PATCH Work?

I just took the latest code base and deployed in my local tomcat server and when I try to execute the PATCH operation, I am getting 403  response?

Regards
Ram

James Agnew

unread,
Jul 12, 2017, 5:45:43 PM7/12/17
to Ram Mittala, HAPI FHIR
Are you using a CORS filter in your deployment?


Cheers,
James

To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.

To post to this group, send email to hapi...@googlegroups.com.

Ram Mittala

unread,
Jul 12, 2017, 6:12:46 PM7/12/17
to James Agnew, HAPI FHIR
Yes, I have added the CORS interceptor login in  JpaServerDemo

/*
* Enable CORS
*/
CorsConfiguration config = new CorsConfiguration();
CorsInterceptor corsInterceptor = new CorsInterceptor(config);
config.addAllowedHeader("Origin");
config.addAllowedHeader("Accept");
config.addAllowedHeader("X-Requested-With");
config.addAllowedHeader("Content-Type");
config.addAllowedHeader("Access-Control-Request-Method");
config.addAllowedHeader("Access-Control-Request-Headers");
config.addAllowedOrigin("*");
config.addExposedHeader("Location");
config.addExposedHeader("Content-Location");
config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"));
this.registerInterceptor(corsInterceptor);


Regards
Ram

James Agnew

unread,
Jul 12, 2017, 6:38:10 PM7/12/17
to Ram Mittala, HAPI FHIR
Hmm, so what is the error you're getting exactly? Is there any message or stack trace in the logs?

Cheers,
James

Ram Mittala

unread,
Jul 12, 2017, 7:12:54 PM7/12/17
to HAPI FHIR, seetharam...@gmail.com
Hi James,

I don't see any error in logs, However, I am getting the HTTP response code as 403 (Forbidden). Attached Screenshot.

And, I have modified the database details in the project (hapi-fhir-jpaserver-uhnfhirtest) and it is working fine and no issues.


Regards
Ram

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
PatientPatach_JPA.png

James Agnew

unread,
Jul 12, 2017, 7:23:02 PM7/12/17
to Ram Mittala, HAPI FHIR
Can you try it using curl instead of postman? If that also fails, please also increase logging to trace level and look for what's causing the 403.

sent from my phone.

To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.

To post to this group, send email to hapi...@googlegroups.com.

Ram Mittala

unread,
Jul 12, 2017, 7:35:35 PM7/12/17
to HAPI FHIR, seetharam...@gmail.com
Hi James,

Finally, it worked. 

Problem is that we have CORS Filters in web.xml as by default and I am focusing on that I added programmatically.

Once I remove the CORS filters from the web.xml file, everything works fine.

I think we should fix this and push the code to JPA Server.

Thanks a lot for your support / help.

Regards
Ram Mittala

James Agnew

unread,
Jul 13, 2017, 1:02:05 PM7/13/17
to Ram Mittala, hapi...@googlegroups.com
Can you try the curl with "curl -v" so it prints the response headers? I have no idea what would cause that.. but maybe the headers will give a hint?

On Thu, Jul 13, 2017 at 12:56 PM, Ram Mittala <seetharam...@gmail.com> wrote:
Hi James,

HTTP - PATCH Operation is working fine if I use the http://localhost:8080/baseDstu3/Patient/52 (both CURL and POSTMAN) , the However same code is not working if I deploy it elsewhere.

I am facing the same problem when I invoke HAPI Test server from my Postman and CURL as well.



4c327593ec15:log mittalas$ curl -X PATCH -H "Content-Type: application/json-patch+json" --data '[  { "op": "replace", "path": "/gender", "value": "male" } ]' http://hapi-fhir.us-west-2.elasticbeanstalk.com/baseDstu3/Patient/52

curl: (52) Empty reply from server


mittalas$ curl -X PATCH -H "Content-Type: application/json-patch+json" --data '[  { "op": "replace", "path": "/gender", "value": "male" } ]' http://fhirtest.uhn.ca/baseDstu3/Patint/70285

curl: (52) Empty reply from server


4c327593ec15:log mittalas$ curl -X PATCH -H "Content-Type: application/json-patch+json" --data '    { "op": "replace", "path": "/gender", "value": "male" }

               ]' https://fhirtest.uhn.ca/baseDstu3/Patient/70285

curl: (52) Empty reply from server


HTTPS is working fine :


mittalas$ curl -X PATCH -H "Content-Type: application/json-patch+json" --data '[  { "op": "replace", "path": "/gender", "value": "male" } ]' https://fhirtest.uhn.ca/baseDstu3/Patient/70285

{

  "resourceType": "OperationOutcome",

  "text": {

    "status": "generated",

    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">INFORMATION</td><td>[]</td><td><pre>Successfully created resource &quot;Patient/70285/_history/6&quot; in 27ms</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t</table>\n\t</div>"

  },

  "issue": [

    {

      "severity": "information",

      "code": "informational",

      "diagnostics": "Successfully created resource \"Patient/70285/_history/6\" in 27ms"

    }

  ]

}


mittalas$ curl -X PATCH -H "Content-Type: application/json-patch+json" --data '[  { "op": "replace", "path": "/gender", "value": "male" } ]' http://localhost:8080/baseDstu3/Patient/52 

{

  "resourceType": "OperationOutcome",

  "text": {

    "status": "generated",

    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">INFORMATION</td><td>[]</td><td><pre>Successfully created resource &quot;Patient/52/_history/5&quot; in 1,829ms</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t</table>\n\t</div>"

  },

  "issue": [

    {

      "severity": "information",

      "code": "informational",

      "diagnostics": "Successfully created resource \"Patient/52/_history/5\" in 1,829ms"

    }

  ]

}

Pls if suggest me if you have any thoughts?

Regards
Ram

On Wed, Jul 12, 2017 at 9:23 PM, Ram Mittala <seetharam...@gmail.com> wrote:
Thanks James for your help.

Regards
Ram

On Wed, Jul 12, 2017 at 4:45 PM, James Agnew <james...@gmail.com> wrote:
Glad it worked!

sent from my phone.

To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.

To post to this group, send email to hapi...@googlegroups.com.

Malcolm McRoberts

unread,
Oct 4, 2017, 9:48:23 AM10/4/17
to HAPI FHIR
In my local sever, I'm also seeing that behavior that I get no response at all to a PATCH request.  I didn't do anything to configure CORS support. What does CORS have to do with PATCH specifically?  Except that I guess there's a list of verbs supported in the CORS config.  Should it not be working even if I don't have CORS?

James Agnew

unread,
Oct 4, 2017, 10:12:14 AM10/4/17
to Malcolm McRoberts, HAPI FHIR
Hi Malcolm,

CORS could definitely be the issue, I don't believe the default config for many CORS filters includes PATCH in the list of verbs it allows so you'd have to add that manually.

Can you try it via curl? If the same request works in curl but not in a browser/postman then you know that it's a CORS issue.

Cheers,
James

On Wed, Oct 4, 2017 at 9:48 AM, Malcolm McRoberts <malco...@gmail.com> wrote:
In my local sever, I'm also seeing that behavior that I get no response at all to a PATCH request.  I didn't do anything to configure CORS support. What does CORS have to do with PATCH specifically?  Except that I guess there's a list of verbs supported in the CORS config.  Should it not be working even if I don't have CORS?

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages