uploadImage via CLI and CSRF check failed error

Hi all,

I am trying to upload a custom favicon into my nextcloud v18 via CLI using curl but I am not sure about the right way to do it. From devtools I see that there is a POST request to server/index.php/apps/theming/ajax/uploadImage. As I see that information is subtmitted via form I have tried this:

curl -u user:password -H ā€œOCS-APIRequest: trueā€ -F ā€˜key=faviconā€™ -F ā€˜image=@"/absolute/path/to/the/favicon.svg"ā€™ -X POST ā€œserver/index.php/apps/theming/ajax/uploadImageā€

I am not sure about if this is the correct way to do it. I am intended to automate the customization. I also receive the following error:
{ā€œmessageā€:ā€œCSRF check failedā€}

Could please anyone help me to figure out where is my error?

thanks

Finally I found the way to save the CSRF token in order to be able to do the POST request using the token and the cookies of the session.