401 error in a custom api
Posted: Mon Jul 08, 2024 10:12 am
hello everyone
I have a 401 error in a custom api
I have the code in Api_Action
$app->get('/getChatByName/{nombre}', function ($request, $response, $args) {
$name = $args["nombre"] ?? null; // Get the input value
if ($name !== null) {
// $response = $response->write(ExecuteScalar("SELECT chat_id FROM usuarios WHERE nombre = '" . AdjustSql($name) . "'")); //
$response = $response->write(ExecuteScalar("SELECT chat_id FROM usuarios WHERE nombre = " . AdjustSql($name))); // Output field value as string
}
return $response; // Return Psr\Http\Message\ResponseInterface object
});
}
and in the table specify client_scrips
$("#x_DESTINATARIO").change(function() {
$.get(ew.getApiUrl(["getChatByName", $(this).val()]), function(res) {
if (res)
$("#x_ChatID").val(res); // Set the result (manipulate it first if necessary) to the target field
});
});
I am logging in as administrator
Failed to load resource: the server responded with a status of 401 (Unauthorized)
the users table is not the security table
phpmaker 2024.13