Skip to main content

Content Negotiation

The FHIR API supports multiple content formats through HTTP content negotiation.

Supported Formats

  • application/fhir+json - FHIR JSON (recommended)
  • application/fhir+xml - FHIR XML
  • application/json - Plain JSON
  • application/xml - Plain XML

Request Format

Specify the content type when sending data using the Content-Type header:
# JSON request
curl -X POST \
     -H "Content-Type: application/fhir+json" \
     -d '{"resourceType":"Patient","name":[{"family":"Doe"}]}' \
     https://your-server.com/fhir/Patient

# XML request
curl -X POST \
     -H "Content-Type: application/fhir+xml" \
     -d '<Patient xmlns="http://hl7.org/fhir"><name><family value="Doe"/></name></Patient>' \
     https://your-server.com/fhir/Patient

Response Format

Request your preferred response format using the Accept header:
# Request JSON response
curl -H "Accept: application/fhir+json" \
     https://your-server.com/fhir/Patient/123

# Request XML response
curl -H "Accept: application/fhir+xml" \
     https://your-server.com/fhir/Patient/123

Default Behavior

If no Accept header is provided, the server defaults to application/fhir+json.

Format Priority

You can specify multiple formats with quality values:
curl -H "Accept: application/fhir+xml;q=0.9, application/fhir+json;q=1.0" \
     https://your-server.com/fhir/Patient/123
The server will return the highest quality format it supports.