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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
I_ia
Frequent Visitor

REST API Authorization

Hi!

I'm trying the REST API, I haven't done this before and the M and DAX languages ​​are weird to me. I tried this on a postman I got this to work well. I tried looking for instructions to do this in Power BI, but that key makes it difficult.
Here is a view of postman javascript, showing that key how to create. Is there any way to make this work in Power BI?

  pm.request.headers.add({key: 'X-Fivaldi-Partner', value: 'ws-XXXX'});

let bodyMD5 = '';
let contentType = '';

if (request.data.length > 0) {
bodyMD5 = CryptoJS.MD5(request.data);
contentType = request.headers['content-type'];
}
let time = Math.floor(new Date().getTime() / 1000).toString();
pm.request.headers.add({key: 'X-Fivaldi-Timestamp', value: time});

let stringToSign = request.method + LF +
bodyMD5 + LF +
contentType + LF;

let headers = pm.request.headers.all();

headers.sort(function (a, b) {
return a.key.toLowerCase().localeCompare(b.key.toLowerCase());
}).forEach(function(header) {
if (header.key.startsWith('X-Fivaldi')) {
let key = header.key.trim().toLowerCase();
let value = header.value;

if (typeof value === 'string') {
value = value.trim();
}

stringToSign += key + ':' + value + LF;
}
});

let url = request.url.replace('http://', '').replace('https://', '');
let path = '';
let queryStr = '';

if (url.includes('?')) {
path = url.substring(url.indexOf('/'), url.indexOf('?'));
queryStr = LF + encodeURI(url.substring(url.indexOf('?') +1));
} else {
path = url.substring(url.indexOf('/'));
}

stringToSign += path + queryStr;
console.log(stringToSign);

stringToSign = CryptoJS.enc.Utf8.parse(stringToSign);
//let key1 = CryptoJS.enc.Utf8.parse(pm.variables.get('partnerSecret'));
let key = CryptoJS.enc.Utf8.parse('xxxxxxxx');

console.log(key);
//console.log(key1);
let hash = CryptoJS.HmacSHA256(stringToSign, key);
let signature = 'Fivaldi ' + CryptoJS.enc.Base64.stringify(hash);
pm.request.headers.add({key: 'Authorization', value: signature});

 

 

 

 

 

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

You are not mentioning which way you want to authenticate. The preferred way seems to be OATH2 via custom connector

 

Handling authentication for Power Query connectors | Microsoft Docs

View solution in original post

3 REPLIES 3
I_ia
Frequent Visitor

Actually, I don’t know what is the best (or only) way to do authentication, in this case.
I like to do desktop (connection and reports) and publish in O365, adding a scheduled update, if is it possible?!

If I make a desktop, does that mean M ​​or DAX language? If so, are there instructions for this type authentication.

I haven't used OAuth2, so I need to learn more about it.

 

Has to be in M, the instructions and sample are in the link I posted.

lbendlin
Super User
Super User

You are not mentioning which way you want to authenticate. The preferred way seems to be OATH2 via custom connector

 

Handling authentication for Power Query connectors | Microsoft Docs

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.