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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

How to format json body to an external REST API

Hi Everyone,

I am a newbie in PowerBI and hope I can get some help here. I need to call an REST API (hosted on AWS Cloud) to apply scrambling on a table column credit card number(CC). My table in Power BI looks like this

foongping_0-1637222360228.png

My AWS Cloud API only support POST method and I have tested it to be working locally on my laptop via Postman. The API will need the body in json and it will output  json  as well

The input string will be something like  (note that the "data" value looks like a list object but it really is only a string literal and I will need to parameterize this using the CC table column)

{"user""leel""data_element""deTokCCN""data": ["1234567890123456"]}

foongping_1-1637222386800.png

What I need to accomplish is to loop through the table CC column and call this Rest API to output the scrambled output instead of the real CC number. I have put together a draft script through googling which looks like this:

let
  url = "https://y0suavjxxx.execute-api.ap-southeast-1.amazonaws.com/foongping_stage/v1/protect",
  body = "{""user"": ""leel"", ""data_element"": ""deTokCCN"", ""data"": [""1234567890123456""]}",
  header = [ #"Authorization"="AWS AWSAccessKeyId=XXXXXXXX",
                         #"Content-Type"= "application/json"],
  Source = Json.Document(Web.Contents(url,[Headers=header,Content=Text.ToBinary(body)]))
in
  Source

 

Now, I have a couple of questions here:

1. If I need to subtitute the hardcoded CC number in the above script, should the body line look like this: 

       body = "{""user"": ""leel"", ""data_element"": ""deTokCCN"", ""data"": ["[CC]"]}"

     such that my API will get exactly this --> {"user""leel""data_element""deTokCCN""data": ["1234567890123456"]}

2. There are no syntax error in the Advance Editor with the above block of code but I am getting this error "Expression.Error: Access to the resource is forbidden". Can you help me understand what's wrong here? Has this something to do with my 'Authorization" header? I specified this "AWS AWSAccessKeyId=XXXXXXXX" based on AWS documentation

foongping_2-1637223025089.png

3. The returned results if I am successful in calling the API will be a json (refer to Postman screen), how will I be able to parse the JSON to extract only the scambled CC number ?

 

Thanks,

FoongPing

 

2 REPLIES 2
Anonymous
Not applicable

Hi, thanks for your reply, I have used an actual key, 'XXXXXX' was because I did not want to reveal the actual key here for security reason.

Gabriel_Walkman
Continued Contributor
Continued Contributor

Not familiar with API requests in Power BI, but I'd imagine you need an actual access key instead of XXXXXXXX?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors