I\'m using RestSharp to call an external API.
This works:
var client = new RestClient(apiUrl);
var request = new RestRequest(myurl, Method.GET);
foreach
To answer your question
AddQueryParameter
adds a parameter in the query string as ParameterType.QueryString
whereas AddParameter(string, object)
adds the parameter as ParameterType.GetOrPost
For more details on each parameter type, see:
GetOrPost
: https://github.com/restsharp/RestSharp/wiki/ParameterTypes-for-RestRequest#getorpost
QueryString
: https://github.com/restsharp/RestSharp/wiki/ParameterTypes-for-RestRequest#querystring
To solve your problem
It seems it is unrelated to the type of parameter, because the exception thrown seems to indicate you aren't even connecting to the remote server.
make sure you pass the same apiUrl
/ myUrl
in both cases.