Forum Discussion
Unleashed inventory system and Power Query
- 4 years ago
You'll have to write your own headers in your Power Query function to send the api-auth-id, api-auth-signature, and other headers requested by the Unleashed API. Authenticate as "anonymous" in Power BI and handle all the authentication requirements in your M code. You're in luck that Unleash is simple as they don't require Oauth tokens.
There's no "standard methology" because every API is different. It's very rare that you'll find M documentation from an API provider, usually you'll have cURL, JavaScript, Python, PHP... the usual suspects. Best place to start is from the vendor sandbox as you did, or use Postman if there's no sandbox.
Chris Webb has good content on his blog about making API calls from Power BI. It's not for the faint of heart, but it can be done. Not the easiest thing to do if you've never used Power Query before as you're likely to go from on roadblock to the next, that said it would be a great learning experience if you have the time and inclination.
Just been working on this and you have to take the API key together with the url parameters, eg, completed for sales orders and pass both into SHA256 encryption and then into binary, that then will enable you to authenticate. Sha256 encryption can't be done inside power query with neither R nor Python supporting the particular modules required.
Once you get the data in then you have to convert the dates from epox to power query dates.... not easily accessible
private static string GetSignature(string args, string privatekey) { var encoding = new System.Text.UTF8Encoding(); byte[] key = encoding.GetBytes(privatekey); var myhmacsha256 = new HMACSHA256(key); byte[] hashValue = myhmacsha256.ComputeHash(encoding.GetBytes(args)); string hmac64 = Convert.ToBase64String(hashValue); myhmacsha256.Clear(); return hmac64;