Skip to content

feature (minor): Per-parameter URL encoding opt-out (Retrofit encoded=true equivalent) #2169

Closed

Description

@glennawatson

Summary

Refit encodes URL [Query] and path segment values automatically, and the only controls are method-level ([QueryUriFormat]) or coarse (TreatAsString). There's no per-parameter way to say "this value is already encoded, pass it through verbatim." This is the feature side of bug #2002 (URL segments getting encoded with no toggle).

Prior art: Retrofit encoded

Retrofit puts an encoded flag on individual parameter annotations — @Query(value, encoded=true), @Path(value, encoded=true), @Field(..., encoded=true), @QueryMap(encoded=true). When set, Retrofit skips URL-encoding for that parameter, letting callers pass pre-encoded values.

Proposal

Add a per-parameter encoding opt-out, e.g. an Encode = false property on [Query] (and a path equivalent), so a single value can bypass automatic encoding while the rest of the request encodes normally. Resolves #2002.

Considerations

  • Interaction with UrlResolutionMode (RefitLegacy vs Rfc3986) and QueryUriFormatAttribute — define precedence (per-param should win).
  • Path-segment opt-out is the case [Bug]: URL Segments getting encoded, with seemingly no way to toggle this #2002 specifically hits; cover both query and path.
  • Reflection + source-generator paths.
  • Document the footgun: caller becomes responsible for producing valid encoded output.

Acceptance criteria

Pointers

Activity

  1. added
    🟢 priority: low
    🔗 area: url-routing
    on Jun 24, 2026
  2. glennawatson commented on Jul 15, 2026

    @glennawatson
    ContributorAuthor

    This is addressed in the Refit 14 beta, now available on NuGet: https://www.nuget.org/packages/Refit/14.0.0-beta.1

    Please give it a try - feedback ahead of the stable 14.0.0 release is very welcome.

    Type-safe REST API clients for .NET, generated from annotated interfaces with build-time source generation, direct request construction, System.Text.Json defaults, and support for trimming and AOT.
  3. github-actions commented on Jul 30, 2026

    @github-actions

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  4. locked as resolved and limited conversation to collaborators on Jul 30, 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

    Featureup-for-grabs✨ enhancement🔗 area: url-routing🟢 priority: low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions