Most probably it works because you are already logged in and have a session token. To access API outside of the browser or live session you have to create a private app token or a public app token with the access scopes you need, more information here -https://help.shopify.com/en/api/getting-started/authentication/private-authentication and https://help.shopify.com/en/api/getting-started/authentication/public-authentication
If you're looking for help here you're going to need to be able to share more information to save everyone from guessing as to what your problem might be. Consider giving some details on how you are making the call (eg, from what stack), what info you are sending, etc.
|an hour ago|
|2 hours ago|