I am a newbie to VS Code environment. I am developing a Web API in VS Code which would later be consumed from client application. Following code block does not seem to be executing so I want to check whether it is at all hitting!
//GET: pwapi/plants/10076/features
[HttpGet("{id}, {sectionArray}")]
public async Task<string> Get(int id, string sectionArray){
var url="https://www.domain.com/search?apikey=<apikey>§ions="+sectionArray+"&plantid="+id;
using(var client = new HttpClient()){
client.BaseAddress=new Uri(url);
client.DefaultRequestHeaders.Accept.Clear();
var response=await client.GetAsync(url);
//will throw an exception if not successful
response.EnsureSuccessStatusCode();
string content = await response.Content.ReadAsStringAsync();
//return await Task.Run(() => JsonObject.Parse(content));
return content;
}
}
URL for the above method is http://localhost:5000/pwapi/plants/10076/features
I have the overloaded method which is working fine:
[HttpGet("{id}")]
public async Task<string> Get(int id){
var url="https://www.domain.com/list?apikey=<apikey>";
using(var client = new HttpClient()){
client.BaseAddress=new Uri(url);
client.DefaultRequestHeaders.Accept.Clear();
var response=await client.GetAsync(url);
//will throw an exception if not successful
response.EnsureSuccessStatusCode();
string content = await response.Content.ReadAsStringAsync();
//return await Task.Run(() => JsonObject.Parse(content));
return content;
}
}
URL for the above method is http://localhost:5000/pwapi/plants/10076
Three questions: 1. How I can debug the code? 2. If debug is not possible (so far I have seen that debug is possible for client scripts only, I may be wrong), what is the alternative way to know where I am doing wrong? 3. If there is no alternative, please tell me why the method is not hitting.
http://localhost:5000/pwapi/plants/10076works fine without appending anything buthttp://localhost:5000/pwapi/plants/10076/featuresdoesn't. "Did you defined a route for multiple parameters" - how can I do this? I am a newbie! :)[Route("pwapi/[controller]")].