Skip to content

Complex query parameter types in non-GET actions #637

Closed

Description

@jamiehowarth0

Hi folks, I'm trying to implement a lightweight Twitter library. This involves doing POST/PUT/DELETE commands, but the parameters are passed by querystring, and not by body. This doesn't appear to be supported despite some previous discussions around complex body params (#89 PR and #102 issue).

Activity

  1. jamiehowarth0 commented on Mar 20, 2019

    @jamiehowarth0
    ContributorAuthor

    I'm slightly further along by creating my own ToString() override and using Reflection, however whilst this serialises my parameters into the URL correctly, the handler expects a key={value} param syntax in the URL for non-GETs. This means that because there's no "key" in the URL segment, serialisation fails.

    What would be really nice would be to assume that any param on the method specified with a QueryAttribute, would be auto-serialized into the URL using the AliasAsAttribute on the properties of the given complex object.

    Syntax example of what I'm trying to achieve:

    [Post("/my/custom-action.json?{settings}")]
    Task DoSomething([Query]object settings);

    settings would be auto-serialised into a querystring using a StringBuilder {setting.propName/AliasAsAttribute.Name}={setting.propValue}

    Or maybe:
    [Post("/my/custom-action.json")]
    Task DoSomething([Query]object queryParams, [Body]bodyParams);

    This would be ideal.

  2. jamiehowarth0 commented on Mar 20, 2019

    @jamiehowarth0
    ContributorAuthor

    Further update: basically the [Query] attribute is being ignored on non-GET methods with parameters. Working on finding a fix.

  3. jamiehowarth0 commented on Mar 20, 2019

    @jamiehowarth0
    ContributorAuthor
  4. added a commit that references this issue on Jun 5, 2019
  5. locked and limited conversation to collaborators on Sep 3, 2019
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions