You may read:
- Enable Debug and check if there is any error raised by your code.
- Using Route_Action server event instead of Custom File
You may read:
Hi,
I am getting no error message for my code.
The called file “rechdocxsave” is a custom file and it works pefectly when I call it with menu (URL) http://192.168.33.46/2022/rechnungsbox2022/rechdocxsave .
I thougt that I kann just call this internally as if I am visiting/clicking the URL.
arbei wrote:
If your code uses session variables, curl() won’t work because you did not pass the cookie.
If you use Advanced Security, session variable is required to get the login status and access the page, your code won’t work by curl() unless the Custom File is set to be accessible by Anonymous user. You may also try to use Route_Action server event as suggested.
Now I have the following code for Route_Action.
I also add the path “mpol/” for the custom file.
And the calling “http://192.168.33.46/2022/rechnungsbox2022/mpol/rechdocxsave” is generating the expected docx.
Is there any hint how to use the session id with curl to have access?
function Route_Action($app)
{
// Example:
$app->get('/mpol/{Id}', function ($request, $response, array $args) {
$MyCode = $args['Id'];
//return $response->withJson(["name" => "myaction"]); // Note: Always return Psr\Http\Message\ResponseInterface object
});
// $app->get('/myaction2', function ($request, $response, $args) {
// return $response->withJson(["name" => "myaction2"]); // Note: Always return Psr\Http\Message\ResponseInterface object
// });
}
mpol_ch
You should remove your Custom File and move the code in the Custom File to the callback for ‘/mpol/{Id}’.
Hi,
what do you mean with “…remove your Custom File and move the code in the Custom File” ?thanks
What arbei meant is do not use Custom Files anymore. Move your code in that Custom File to callback in Route_Action server event.