Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

API connection to App Store

Hi, I'm trying to connect to our appstore account to retreive stats on app downloads.  

The power query M code I've been trying is based on the API specification file downloadable from here and also I used took some guidance from the end of this article about JSON code here 

...The M code I'm using at the moment is below, I'm getting an error message in Power Query saying 'Please specify how to connect [Edit credentials]'. Do I need to specify the connection this in the M code, if so I'm not sure how to do this?!... I'm new to using private key type APIs like this so hoping someone can advise where I'm going wrong please 🙏

 

let
Source =
Web.Contents(
"https://api.appstoreconnect.apple.com/",
[
RelativePath = "v1/salesReports",
Query=
[
key_id ="###ourkeyid###"
,issuer_id ="###ourissuerid###"
,key="-----BEGIN PRIVATE KEY-----\n###ourkey###\n-----END PRIVATE KEY-----"
//,duration= 1200, // optional (maximum 1200)
//,in_house= false // optional but may be required if using match/sigh,
]
]
)
in
Source

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Given the nature of the error message you're receiving in Power Query, it appears that Power Query is prompting you to specify how to connect because it doesn't automatically recognize the authentication method required by the API you're trying to access. In cases involving APIs that require private key authentication, you typically need to handle the authentication process programmatically within your M code, which involves generating a token based on your private key and other credentials, and then passing this token as part of your API request headers.
However, the M code snippet you've shared seems to attempt to include the private key directly in the query parameters, which is not the standard method for APIs requiring private key authentication. Instead, you would generally need to:
1. Generate a JWT (JSON Web Token) using your private key and other necessary credentials.
2. Use this JWT to request an access token from the API's authentication endpoint.
3. Include the access token in the header of your API requests.

For a general understanding of handling API connections in Power Query M, you can refer to the documentation on Web.Contents function:
Web.Contents - PowerQuery M | Microsoft Learn
Web.Headers - PowerQuery M | Microsoft Learn
www.dalesandro.net

vjunyantmsft_0-1709799105491.png

Here I have helped you find some of the correct ways to write it:
Solved: Connecting API - Microsoft Fabric Community
Solved: Connecting to API - Page 2 - Microsoft Fabric Community

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

Given the nature of the error message you're receiving in Power Query, it appears that Power Query is prompting you to specify how to connect because it doesn't automatically recognize the authentication method required by the API you're trying to access. In cases involving APIs that require private key authentication, you typically need to handle the authentication process programmatically within your M code, which involves generating a token based on your private key and other credentials, and then passing this token as part of your API request headers.
However, the M code snippet you've shared seems to attempt to include the private key directly in the query parameters, which is not the standard method for APIs requiring private key authentication. Instead, you would generally need to:
1. Generate a JWT (JSON Web Token) using your private key and other necessary credentials.
2. Use this JWT to request an access token from the API's authentication endpoint.
3. Include the access token in the header of your API requests.

For a general understanding of handling API connections in Power Query M, you can refer to the documentation on Web.Contents function:
Web.Contents - PowerQuery M | Microsoft Learn
Web.Headers - PowerQuery M | Microsoft Learn
www.dalesandro.net

vjunyantmsft_0-1709799105491.png

Here I have helped you find some of the correct ways to write it:
Solved: Connecting API - Microsoft Fabric Community
Solved: Connecting to API - Page 2 - Microsoft Fabric Community

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors