0

I'm working on a project where I need to send HTTP requests using RestSharp in C#. These requests require custom headers, some of which may contain special characters or non-ASCII characters, such as German letters like ä, ö, ü in both the name and the value.

I'm aware that HTTP headers should ideally be within the ASCII character set range, but in my case, I need to include these special characters. However, I'm unsure about the best practices for handling such headers in RestSharp.

Could someone advise on the recommended approach for passing custom headers with special characters in RestSharp? Should I encode the characters in some specific format, or does RestSharp handle this automatically? Any insights or examples would be greatly appreciated. Thank you!

1 Answer 1

0

RestSharp encodes parameters of any type by default.

You can override the default encoding by using the Encoding property of RestClientOptions. You can also instruct RestSharp not to encode parameters by setting encode argument to false when using AddParameter. However, content parameters are added using .NET content classes, which might enforce the encoding.

Not the answer you're looking for? Browse other questions tagged or ask your own question.