简体   繁体   中英

c# .net framework web api controller error 404 not found

I am an noob in .net framework web api c# so my question is when i try to recieve webhook data the web hook test function that sends data gives a 404 error. I try to call the webhook reciever controller with...:3001/api/USIAccountWebhook. I can call...:3001/api/Values with no problem at all.

Beginning of the controller code where i think I'm going wrong:

public class USIAccountWebhookController : ApiController
{

    [System.Web.Http.Route("webhooks/accountupdated")]
    public async Task<GenericResponseDTO> AccountUpdatedAsync(AccountDTO value)
    {
        string EPrelationID;
        //SecretKey from the notification should always be checked for security.
        if (value.SecretKey != SecretKey)
        {
            throw new HttpResponseException(HttpStatusCode.Unauthorized);
        }

<< Does anyone maybe have an idea or tips? Thanks!

Best regards, Jeroen

404 is a very common error that says you taht the URI you're calling did't exist, the Controller code you shared informs us that the correct route for the method you're trying to call is:

...:3001/api/webhooks/accountupdated

as stated here:

[System.Web.Http.Route("webhooks/accountupdated")]

Just to bne sure, also search for something like:

 [RoutePrefix("some_url_chunks_more")]

(you need to call the method, not the class)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM