Hi @Aashima
I suggest you try accessing the URL in your browser to make sure that it is publicly accessible and the API endpoint is working as expected.
Make sure you're choosing the correct authentication method. For an API key, you typically need to use Web API authentication.
If the API you're calling requires the API key in the request header, in Power Query Editor, select Home > Advanced Editor.
Modify the M code to include the API key in the headers. The reference: Data from web - DataSource.Error - unable to retrieve contents of page
If you have more issues on M code, it's recommended to post a new thread in power Query forum: https://community.fabric.microsoft.com/t5/Power-Query/bd-p/power-bi-services
There are experts there who can give more comprehensive advice. Thanks for your understandings.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.