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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
NaukkaUKKO
Frequent Visitor

API request what needs HMAC SHA-256 encryption

Hello,

 

I need to request data from API to Power Query, but request payload needs SHA-256 encryption. Googling reveals years old posts where people state that its not possible to use this cryptograhy in Power Query. I would appreciate your help if you knew if its still the case or there is work around. Below is code of how i would do request to API with Python. 

 

API_ROOT = 'xxxxxxxx'

 

public_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'


private_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'


call_string = 'events/<event_id>?query1=value1&query2=value2'


timestamp_sec = int(time.time())

msg = ','.join([public_key,
str(timestamp_sec),
call_string,])

 

signature = hmac.new(
private_key.encode('utf-8'),
msg=base64.b64encode(msg.encode('utf-8')),
digestmod=hashlib.sha256
).hexdigest()

 

headers = {
'Accept': 'application/json; charset=utf-8',
'Authorization': 'xxxx public_key={}, timestamp={}, signature={}'.format(public_key, timestamp_sec, signature),
}

request = urllib.request.Request(API_ROOT + call_string, headers=headers)
response = urllib.request.urlopen(request)
data = json.loads(response.read())

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @NaukkaUKKO ,

 

There is no HASH encryption in Power Query. But, Power Query supports Python script. Then you can copy the code you provided in Power query.

The type of python script result is json, you can use power query funtion Json.Document() to receive this result.

Run Python Scripts in Power BI Desktop - Power BI | Microsoft Docs

 

Best Regards

Community Support Team _ chenwu zhu

 

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-chenwuz-msft
Community Support
Community Support

Hi @NaukkaUKKO ,

 

There is no HASH encryption in Power Query. But, Power Query supports Python script. Then you can copy the code you provided in Power query.

The type of python script result is json, you can use power query funtion Json.Document() to receive this result.

Run Python Scripts in Power BI Desktop - Power BI | Microsoft Docs

 

Best Regards

Community Support Team _ chenwu zhu

 

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

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors