I want to set my BaseUrl as a string but client.BaseUrl returns a URI, because I have my generic GET and POST methods that use it but I am running into this issue
private static bool setBaseURL(string baseURL)
{
if (baseURL == null || baseURL.Empty())
{
Console.WriteLine("Please pass the correct base URL....");
return false;
}
try
{
RestClient client = new RestClient();
client.BaseUrl = baseURI;
return true;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return false;
}
}
//Here is my GET and POST method for reference
public static IRestResponse doGet(string contentType, string baseURI, string basePath,
string token, Dictionary<String, String> paramsMap)
{
if (setBaseURI(baseURI))
{
IRestRequest request = sendRequest(contentType, token, paramsMap);
return getResponse("GET", request, basePath);
}
return null;
}
public static IRestResponse doPost(string contentType, string baseURI, string basePath,
string token, Dictionary<String, String> paramsMap, Object obj)
{
if (setBaseURI(baseURI))
{
IRestRequest request = sendRequest(contentType, token, paramsMap);
addRequestPayload(request, obj);
return getResponse("POST", request, basePath);
}
return null;
}
What I have tried:
I am not sure their is a method client.BaseHost .. not sure if I can use this
client.BaseHost = baseURI