Skip to content

URL builder should support ?f= query parameter for format negotiation (Accept header ignored by OSH) #99

Closed as not planned

Description

@Sam-Bolling

Summary

The library's URL builder (CSAPIQueryBuilder) currently constructs detail URLs like /procedures/{id} and relies on the HTTP Accept header for content negotiation (e.g., Accept: application/sml+json to request SensorML). However, several real-world OGC API servers — notably OpenSensorHub (OSH) — ignore the Accept header and require a ?f= query parameter for format selection instead.

This means the library cannot request alternate representations (SensorML, HTML, etc.) from servers that only support query-parameter-based negotiation without the consumer manually appending ?f=... to the URL — defeating the purpose of the URL builder.

Observed Behavior

Server: OpenSensorHub at http://45.55.99.236:8080/sensorhub/api

Request:

GET /sensorhub/api/procedures/040g
Accept: application/sml+json, application/json

Expected Response: SensorML JSON (application/sml+json)

Actual Response: GeoJSON Feature (application/json) — the server ignores the Accept header entirely.

The server's response does include an alternate link pointing to the SensorML representation:

{
  \"rel\": \"alternate\",
  \"title\": \"This procedure resource in SensorML format\",
  \"href\": \"http://45.55.99.236:8080/sensorhub/api/procedures/040g?f=sml3\",
  \"type\": \"application/sml+json\"
}

This confirms the server supports SensorML — it just requires ?f=sml3 instead of Accept header negotiation.

Affected Endpoints

This applies to any resource that has multiple representations. Known cases:

Resource Format Accept Header Query Parameter
Procedures SensorML 3.0 application/sml+json ?f=sml3
Procedures HTML text/html ?f=html
Systems SensorML 3.0 application/sml+json ?f=sml3
Any resource GeoJSON application/geo+json ?f=json

The specific ?f= token values are server-dependent (OSH uses sml3, other servers may use sml+json or sensorml).

Proposed Solution

Add an optional format (or f) parameter to the URL builder's detail and list methods, so consumers can request alternate representations via query parameter when the server doesn't honor Accept headers.

Option A: Add format to existing query options

interface QueryOptions {
  limit?: number;
  offset?: number;
  format?: string;  // ← NEW: appended as ?f={value}
  // ...
}

// Usage:
builder.getProcedure(id, { format: 'sml3' })
// → /procedures/040g?f=sml3

Note: This option depends on #100 being resolved first — currently, getProcedure(id) calls assertResourceAvailable('procedures'), which throws if the resource wasn't discovered as a top-level link, before any query options are even processed.

Option B: Add a dedicated format method

builder.getProcedure(id).withFormat('sml3')
// → /procedures/040g?f=sml3

Option C: Support both Accept header AND ?f= parameter

A higher-level approach where the library's fetch layer tries Accept first, and if the response content type doesn't match, checks for an alternate link and follows it — similar to the workaround implemented in the CSAPI Explorer demo's SensorMLDisplay.vue component (commit ff8b1c5).

OGC API Specification Context

The OGC API — Common Part 1 specification supports both content negotiation mechanisms:

  • §7.7 (HTTP Content Negotiation): Servers SHOULD support Accept headers
  • §7.8 (Parameter-based Negotiation): Servers MAY support a f query parameter as an alternative

Both are valid per the spec, but the library currently only facilitates the Accept header path. Supporting the ?f= parameter would make the library work correctly with a broader range of compliant servers.

Cross-Server Findings

Server Accept Header Honored? ?f= Parameter Supported?
OpenSensorHub (OSH) ❌ No ✅ Yes (?f=sml3)
52North CSAPI Demo ⚠️ Partial ✅ Yes

Current Workaround

In the CSAPI Explorer demo app, SensorMLDisplay.vue works around this by:

  1. Sending Accept: application/sml+json
  2. If the response is GeoJSON (not SensorML), scanning response.links[] for an alternate link with type: \"application/sml+json\"
  3. Following that alternate link (which contains the ?f=sml3 parameter)

This works but forces every consumer to implement their own fallback logic. The URL builder should make this unnecessary.

Interaction with #100

This issue is compounded by #100 (assertResourceAvailable() is overly strict for per-ID methods). Even if format were added to QueryOptions, calling builder.getProcedure(id, { format: 'sml3' }) would still throw on OSH because procedures may not be in availableResources — the assertion fires before the URL (including the ?f= parameter) is ever constructed. Both issues need to be resolved for the URL builder to work reliably with real-world servers.

References

Activity

  1. added a commit that references this issue on Feb 21, 2026
  2. Sam-Bolling commented on Feb 21, 2026

    @Sam-Bolling
    Author

    Closing as not planned — the requested capability already exists.

    QueryOptions.f?: MimeType is already defined in model.ts (L138), and buildQueryString() already serializes it to ?f={value}. Consumers can pass { f: 'sml3' } to any per-ID method (e.g., builder.getProcedure('040g', { f: 'sml3' })) to get query-parameter-based format negotiation today.

    The demo app's workaround was unnecessary for Part 1 resources. The actual blocker for Part 2 resources is #100 (assertResourceAvailable() throwing before URL construction), which is a separate concern.

    Full findings report: docs/testing/demo-app-findings/issue-99-format-query-parameter.md

  3. added a commit that references this issue on Feb 21, 2026
  4. added a commit that references this issue on May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementinteroperability

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions