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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ntanalyze
Frequent Visitor

Running API with One time user password

Hi

 

I'm trying to connect to another part system using API.

 

The API requires the user to be authenticated to the system using the “Login” action. Once
the user is authenticated successfully, he can call the required actions according to the
specification.

 

The Login API: https://www.expertpowerplus.com/API/api/Login?userName=demo&pass=12345678

 

The Extract data API:

https://www.expertpowerplus.com/API/api/Consumption/ConsumptionWithPrices?usageType=ActiveEnergyImpo...

 

Whe I used postman I used the login API as a pre-request script and it work.

 

However when i tried to extract the data using Power Query it said:

 

"We Couldn't authenticate with the credentails provided.

 

My query is:

 

let
timeout = #duration(0, 0, 5, 0),
url = Json.Document(Web.Contents("https://www.expertpowerplus.com/API/api/Login?userName=user&pass=password")),
body="{ ""usage_type"":1,
""StartDate"": ""2022-12-01"",
""EndDate"": ""2022-12-29"",
""PeriodType"": 3,
""DeviceList"": [
171887],
}",
Source = Json.Document(Web.Contents("https://www.expertpowerplus.com/API/api/Consumption/ConsumptionWithPrices?usageType=ActiveEnergyImpo...",
[Timeout=timeout,
Headers=[#"Content-Type"="application/json; charset=utf-8"],
Content=Text.ToBinary("")]), 65001),
data = Source[data],
#"Converted to Table" = Record.ToTable(data)
in
#"Converted to Table"

 

Please your help.

 

Best Regards

 

Nir Tal

2 REPLIES 2
lbendlin
Super User
Super User

you seem to have a circular reference

 

data = Source[data]

 

I think you meant to say

 

data = url[data]

 

Fix the login step first before attempting the data retrieval step.

Hi

 

Thank fir your answer, but it still didn't solve the problem.

It keep asking me for credentials.

As i said the credentials provided in the first url.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors