API not quite working

I tried to connect to a local device with the API in Windows 10. I use the command

curl -k -c cookies.txt -H “Content-Type: application/json” -X POST -d ‘{“username”:“admin”,“password”:“8characters!9”}’ https://192.168.50.1/api/login

from the command prompt with admin rights. What I receive is a

{
“stat”: “fail”,
“code”: 301,
“message”: “Unauthorized”
}

altough the user and password is correct. I tried manuals, the forum and so on. What am I doing wrong?

Hi @Dude2048 welcome to the forum. Login example from device API manual should work:
curl -c cookies.txt -H “Content-Type: application/json” -X POST -d
‘{“username”:“user”,“password”:“pass”}’ http://192.168.1.1/api/login
Link to the latest manual:
https://download.peplink.com/resources/Peplink-Router-API-Documentation-for-Firmware-8.1.1.pdf
Do you have Redirect HTTP to HTTPS disabled under System > Admin Security ? This error can be seen most of the time due to wrong used login credentials.

I used the latest manual, latest firmware, http to https direction (hence the -k option in curl to suppress the certificate). The command I used is the same that you gave to me.
Hardware used is a HD2 MAX hw revision 2.