Why can't I use Python for the "https://www.hackthebox.eu/api/invite/generate" post request?

When I was trying to crack the Hack The Box Sign In Page, I tried to use Python requests to make a post request to https://www.hackthebox.eu/api/invite/generate, but it just says something like Response [404]. Why?

The code:
import requests

response = requests.post(‘https://www.hackthebox.eu/api/invite/generate’)

print(response.text)

Note:
I used https://curl.trillworks.com/ to convert:

curl -XPOST https://www.hackthebox.eu/api/invite/generate

to:

import requests

response = requests.post(‘https://www.hackthebox.eu/api/invite/generate’)

Also, hi. I’m new here

Hi. Have a nice day ?.

same request fails with two different tools? there must be some sort of difference between them that makes the server respond in a different way

Ok thanks.

also browser console can help

I agree with the @zhengzufu 's point, make use of the headers

HEADERS = { 'User-agent': 'Mozilla 5.0'}
url_ = 'https://www.hackthebox.eu/api/invite/generate'

response = requests.post(url=url_, headers=HEADERS)

might help