Why is the following code not called when I test the route http://127.0.0.1:3005/api/v1/getInvoice?

This is my code

#[get("/getInvoice")]
pub async fn get_invoice_handler(invoice_filters: web::Json, req: HttpRequest) -> Result<HttpResponse, CustomError> {
match verify_auth(req.headers()) {
Ok(true) => {
......
Ok(HttpResponse::Ok().json(invoice_filters))
},
Ok(false) => Err(CustomError::new(401, "Not authorizated".to_string())),
Err(_) => Err(CustomError::new(999, "Unknown error".to_string()))
}
}

Show message not found :persevere:
I use as headers: Authorization and x-api-key.
And how json do I use
{
"hash": "xxxx"
}

What framework are you using? actix-web? Have you added the route to your server? And if so, have you made sure it resides in your /api/v1/ scope?

Yes, I am using actix_web, and the route has web::scope("/api/v1")

Can you share the code where you create your server? Are other routes in your scope reachable? Have you maybe accidentally added a trailing / to your scope?

I am modifying this code.

I still can't publish my change

I have added this parameter
req: HttpRequest
and the logic of req.headers() and validation

Can you reach the endpoint when you revert your changes?

Yes, before the change it was working (using a lightning node).

The case was resolved, it originated from the import of a request to test the API (windows/linux)

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.