In my case, I copied the curl command from Confluence to TextEdit. After spending almost an hour, and trying to paste the command in different text editors in order to sanitize, finally, PyCharm helped me (IntelliJ should help too)
After pasting it in PyCharm I got to see the error
After removing these "NBSP" (non-breaking spaces), the command started running fine.