because of using /
or %2f
in route values, I suspect that the main problem at server side should be:
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
And to solve it you can change routing to this:
api/Trinity/GetDirectoryAndTask/{modelTemplateId}/{*taskName}
To test if the server side is OK, paste the url in browser and get the result.
But for your client the error is related to the way you read data from that api. I use this code and it reads data after I changed the route:
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(" http://localhost:46789/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await client.GetAsync("api/Trinity/GetDirectoryAndTask/9/AG33%2f34");
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsAsync<KeyValuePair<string, string>>();
//The result is a valid key/value pair
}
}