Welcome to the Atlassian developer community @srinivasanr.
Unfortunately, the documentation, sample code, and error messages are misleading for use with API tokens. At the top of the REST API documentation is a section on Version and URI that explains:
The URIs for resources have this structure:
https://<site-url>/rest/api/3/<resource-name>
For example,https://your-domain.atlassian.net/rest/api/3/issue/DEMO-1
The documentation on using API tokens subtly documents this with the curl example:
curl -v https://mysite.atlassian.net --user me@example.com:my-api-token
I think you are getting a 404 error because you have colons around the cloud ID. Otherwise, I think you would get a 401 to indicate you are using the wrong auth mechanism.
Other than the URL in the fetch
call, everything looks correct. Maybe too correct. I hope you didn’t post a real API token! If you have, I recommend you revoke it immediately.