I am getting an error message of (STATUS Code 404 method not found) while reading an api through asp.net core web app, here is my api code
[HttpGet("ParticipantID")] public async Task<ActionResult<Participant>> GetParticipantsByParticipantID(long ParticipantID) { var participant_id = await context.Participants.FindAsync(ParticipantID); if (participant_id == null) { return NotFound(); } return Ok(participant_id); }
while a call to api code is here
`[HttpGet]
public IActionResult Edit(long ParticipantID)
{
url = configuration.GetValue(“apiurl:baseurl”);
url = url + “participant/”;
Participants participant = new Participants();
HttpResponseMessage response = client.GetAsync(url + ParticipantID).Result;
if(response.IsSuccessStatusCode)
{
string result = response.Content.ReadAsStringAsync().Result;
var data = JsonConvert.DeserializeObject<Participants>(result);
if(data != null)
{
participant = data;
}
}
return View();
}`
As i am a new to core i will be thankful if someone can help me on it
Regard
Here is the code for my aspsettings.json file
"apiurl": { "baseurl": "https://localhost:7194/" },
Mirza Fariad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.