Search code examples
hl7-fhirhapi

HL7 HAPI-FHIR add cookie to the client request


Is it possible to add cookie to the request while using IRestFulClient from HAPI-FHIR?


Solution

  • This could be done quite easily by creating a custom interceptor which adds a cookie header. You can see an example of a client interceptor which adds an authorization header here. If you copy that code but change the header from "Authorization" to "Cookie", then register the interceptor by calling

    client.registerInterceptor(interceptor);
    

    ..you will get that behaviour.

    Incidentally, if you create such an interceptor and wanted to share it back with the project, we'd love to have it! :)