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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
mariewo
Regular Visitor

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
v-junyant-msft
Community Support
Community Support

Hi @mariewo ,

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
v-junyant-msft
Community Support
Community Support

Hi @mariewo ,

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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