Developer Blog

Issues using RestSharp with UserVoice API

in API

I've recently had a few people having issues with the RestSharp library for DotNet. Digging into the code for RestSharp if found that during the encoding process the values of parameters are correctly encoded but the names where being left. You can solve this by change line 161 in OAuth1Authenticator.cs from:

parameters.Add(new WebPair(p.Name, p.Value.ToString()));

to

var encodedName = OAuthTools.UrlEncodeStrict(p.Name.ToString());
parameters.Add(new WebPair(encodedName, p.Value.ToString()));

and recompiling RestSharp. The value is encoding later in the OAuth workflow in OAuthTools.cs. I suspect there is a neater solution, which I'll have a think about before submitting a pull request. In the meantime this will get you going. The part of the spec that refers to this states:

3.4.1.3.2.  Parameters Normalization

   The parameters collected in Section 3.4.1.3 are normalized into a
   single string as follows:

   1.  First, the name and value of each parameter are encoded
       (Section 3.6).

~ Scott

Like us on Facebook Join us on Google+
blog comments powered by Disqus
product screenshot

Create a UserVoice account

Discover how easy it can be to provide great customer service

Try it for free