Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
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
Solved! Go to Solution.
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
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.
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
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.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
35 | |
17 | |
12 | |
11 | |
9 |
User | Count |
---|---|
45 | |
27 | |
16 | |
14 | |
14 |