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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
raquelm
New Member

Power BI – Binary.Length = -1 when calling Winfra API (works in Postman)

Hello, I'm trying to obtain a Winfra 3 API token from Power BI (Power Query M). In Postman, the POST request to http://185.253.153.45/winfra3/api_token/ returns the token in JSON without issue. In Power BI:

The call using Web.Contents appears to execute, but Binary.Length(response) returns -1.

If I try to read the content, I receive conversion errors (Binary → Text).

I suspect the server is returning compressed JSON without the Content-Encoding header, or that Power BI is blocking the body due to Web.Contents policies when using a direct IP address.

 

Results:

In Postman: Readable JSON { "token": "xxxxx", ... }.

In Power BI: len = -1 and if Power BI tries to preview the response, it displays "We cannot convert a value of type Binary to type Text".

What I've already tried:

Forcing Accept-Encoding = "identity".

Sending host + RelativePath (not yet finalized).

Attempts at Binary.Decompress(response, Compression.GZip) and Compression.Deflate (unsuccessful because Power BI doesn't return a body).

Specific question: Has anyone managed to consume the Winfra API from Power BI? What tricks did you use (proxy, RelativePath, specific headers, gateway, enterprise gateway, or changing User-Agent)? Any experience with servers that deliver compressed responses without Content-Encoding and how did you handle it in Power Query?

Thanks.

2 REPLIES 2
v-pnaroju-msft
Community Support
Community Support

Thankyou, @DataVitalizer for your response.

Hi raquelm,

We appreciate your inquiry through the Microsoft Fabric Community Forum.

We would like to inquire whether have you got the chance to check the solution provided by @DataVitalizer  to resolve the issue. We hope the information provided helps to clear the query. Should you have any further queries, kindly feel free to contact the Microsoft Fabric community.

Thank you.

DataVitalizer
Solution Sage
Solution Sage

Hi @raquelm 


You’re right, Power BI shows Binary.Length = -1 when the server sends compressed JSON without a proper Content‑Encoding header.

The fix is to force plain JSON and then parse it manually, here is an exxample:

let
url = "http://185.253.153.45/winfra3/api_token/",
body = "{""username"":""yourUser"",""password"":""yourPass""}",
response = Web.Contents(
url,
[
Content = Text.ToBinary(body),
Headers = [
#"Content-Type" = "application/json",
#"Accept" = "application/json",
#"Accept-Encoding" = "identity",
#"User-Agent" = "PowerQuery"
]
]
),
asJson = Json.Document(Text.FromBinary(response, TextEncoding.Utf8))
in
asJson


The key trick is to add Accept-Encoding = identity so the server returns uncompressed JSON, then wrap with Text.FromBinary to Json.Document.

 

Did it work? 👍 A kudos would be appreciated
🟨 Mark it as a solution to help spread knowledge 💡

 

🟩 Follow me on LinkedIn

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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 Solution Authors