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.