You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Complex query parameter types in non-GET actions #637
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).
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.
Activity
jamiehowarth0 commentedon Mar 20, 2019
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);
settingswould be auto-serialised into a querystring using aStringBuilder{setting.propName/AliasAsAttribute.Name}={setting.propValue}Or maybe:
[Post("/my/custom-action.json")]
Task DoSomething([Query]object queryParams, [Body]bodyParams);
This would be ideal.
jamiehowarth0 commentedon Mar 20, 2019
Further update: basically the [Query] attribute is being ignored on non-GET methods with parameters. Working on finding a fix.
jamiehowarth0 commentedon Mar 20, 2019
One test written and failing:
https://github.com/benjaminhowarth1/refit/commit/c528c293170aa0265c24f2d70f434209ba733bf7
Merge pull request #629 from benjaminhowarth1/master