http
http copied to clipboard
Incomplete Headers from POST Request
I'm trying to POST a response to a server, and I'm able to do so successfully. However, the response headers for Dart are incomplete, and there is information in the missing headers that I need. Specifically, I'm posting to this URL:
https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/Patient?_format=json&_pretty=false
And I'm posting this JSON content:
{"resourceType":"Patient","identifier":[{"type":{"coding":[{"system":"http://hl7.org/fhir/sid/us-ssn","code":"SB"}]},"system":"urn:oid:2.16.840.1.113883.4.1","value":"444114567"}],"name":[{"use":"usual","text":"DerrickLin","family":"Lin","given":["Derrick"]}],"gender":"male","birthDate":"1973-06-03"}
When I post it using the http package, either with http.post or creating a client and watching the stream, I'm successful. I receive a 201 response, and I can check and see that I've successfully created the new resource. So all of that seems to work, no problem. However, in order to identify the newly created resource, there is a header that is passed back as part of the creation process that I'm not getting in Dart. If I make the above post, these are the headers I get from the response:
{
"cache-control": "no-cache,no-store",
"content-length": 0,
"content-type": "application/fhir+json; charset=utf-8",
"expires": -1,
"pragma": "no-cache"
}
However, if I throw an exception right before the request is made, pull out the exact same token and copy/paste it into Postman (along with the same url and same payload), so the request should be essentially identical, I get the following headers:
{
"cache-control": "no-cache,no-store",
"content-length": 0,
"content-type": "application/fhir+json; charset=utf-8",
"expires": -1,
"pragma": "no-cache",
"location": "Patient/e2TbouQiVdAQACIu1MV4TaA3"
}
Postman also includes CORS headers (Access-Control-Allow-Headers, etc), but I'm not interested in those so I didn't include them. Is there a way to get ALL of the headers returned from a request? In order for my application to function properly, I need to be able to retrieve that "location" header when I post something.