nmcli randomly gives below error for some wifi connections but for others it works fine.
This seems to be a problem with nmcli. Have you tried rebooting the device and checking if the problem still persists? If it does, then this link could also be helpful? Let us know if this does not solve the issue.