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
*[Buffering and the Content-Length header](#buffering-and-the-content-length-header)
47
49
*[JSON content](#json-content)
@@ -175,7 +177,9 @@ Search("admin/products");
175
177
>>>"/search/admin/products"
176
178
```
177
179
178
-
### Dynamic Querystring Parameters
180
+
### Querystrings
181
+
182
+
#### Dynamic Querystring Parameters
179
183
180
184
If you specify an `object` as a query parameter, all public properties which are not null are used as query parameters.
181
185
This previously only applied to GET requests, but has now been expanded to all HTTP request methods, partly thanks to Twitter's hybrid API that insists on non-GET requests with querystring parameters.
To customize the format of query keys, you have two main options:
281
+
282
+
1.**Using the `AliasAs` Attribute**:
283
+
284
+
You can use the `AliasAs` attribute to specify a custom key name for a property. This attribute will always take precedence over any key formatter you specify.
2.**Using the `RefitSettings.UrlParameterKeyFormatter` Property**:
311
+
312
+
By default, Refit uses the property name as the query key without any additional formatting. If you want to apply a custom format across all your query keys, you can use the `UrlParameterKeyFormatter` property. Remember that if a property has an `AliasAs` attribute, it will be used regardless of the formatter.
313
+
314
+
The following example uses the built-in `CamelCaseUrlParameterKeyFormatter`:
**Note**: The `AliasAs` attribute always takes the top priority. If both the attribute and a custom key formatter are present, the `AliasAs` attribute's value will be used.
339
+
340
+
#### Formatting URL Parameter Values with the `UrlParameterFormatter`
341
+
342
+
In Refit, the `UrlParameterFormatter` property within `RefitSettings` allows you to customize how parameter values are formatted in the URL. This can be particularly useful when you need to format dates, numbers, or other types in a specific manner that aligns with your API's expectations.
343
+
344
+
**Using `UrlParameterFormatter`**:
345
+
346
+
Assign a custom formatter that implements the `IUrlParameterFormatter` interface to the `UrlParameterFormatter` property.
In this example, a custom formatter is created for date values. Whenever a `DateTime` parameter is encountered, it formats the date as `yyyyMMdd`.
369
+
370
+
**Formatting Dictionary Keys**:
371
+
372
+
When dealing with dictionaries, it's important to note that keys are treated as values. If you need custom formatting for dictionary keys, you should use the `UrlParameterFormatter` as well.
373
+
374
+
For instance, if you have a dictionary parameter and you want to format its keys in a specific way, you can handle that in the custom formatter:
0 commit comments