You're trying to call a method which accepts two strings, but you're trying to pass in a
Dictionary<string, string>
.
Computers don't just "guess" what you meant to do; they do exactly what you tell them to do. If you tell it to call a method called
AddQueryParameter
passing in a
Dictionary<string, string>
, the computer will - correctly - tell you that there is no such method.
You need to iterate over the values in the dictionary and add them separately:
if (paramsMap != null)
{
foreach (KeyValuePair<string, string> pair in paramsMap)
{
request.AddQueryParameter(pair.Key, pair.Value);
}
}
You're getting an
"unassigned local variable" error because you haven't assigned a value to the
request
parameter. And no, you can't set it to
null
, because then you'd get a
NullReferenceException
at run-time. You need to create a new request instance and store it in that variable before you try to do anything with the variable.