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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
meyron
Regular Visitor

Web.Content Section=ResponseHeader Detail=CR must be followed by LF

Good day.

I'm creating a custom API connector with Power Query. When testing on localhost domain, everything is just great, but when I attempt to make requests over live domain, I get error `Section=ResponseHeader Detail=CR must be followed by LF` (similar description: here).
Have searched a lot related to this issue, but never found any solution for this.
As I understand `Web.Content` is using .NET System.Web, and one of suggested solutions was to create .config file with `useUnsafeHeaderParsing=true` as:

<system.net> 
  <settings> 
   <httpWebRequest useUnsafeHeaderParsing="true" /> 
  </settings> 
</system.net>

I'm newbie at VisualStudio and PowerQuery (just 1 day of development), so maybe someone can direct me where and how should I place .Net configuration file for `useUnsafeHeaderParsing`. If it might be related to .NET and can give a workaround.

Checking on live response headers with curl, I've not found any invalid chars in headers (like in case here).

Or best if anyone can describe some solutions for this. 

Sample code used:

getTokenTest = () =>
    let
        client_id     = Extension.CurrentCredential()[Username],
        client_secret = Extension.CurrentCredential()[Password],
        
        PostBody = Text.ToBinary(Uri.BuildQueryString([
            client_id = client_id,
            client_secret = client_secret,
            response_type = "token"
        ])),

        Response = Web.Contents(Text.Combine({API_URL, "/token"}), [
            Content = PostBody,
            Headers=[#"Content-type" = "application/x-www-form-urlencoded; charset=utf-8",#"Accept" = "application/json"]])
    in
        Response;

 
Any workaround would be appreciated 🙂

3 REPLIES 3
Jayendran
Solution Sage
Solution Sage

Hi @meyron 

 

One workaround I'd give is

 

You can write a powershell script/even the dotnet code to generate the API from the server. 

 

Using a cron-job/ Task schedular to run the script for every n min from your server, to generate and dumpt the token in a file.

 

From powerbi use the file as the source and read the token.

 

I've done the same approach in my article below

https://community.powerbi.com/t5/Community-Blog/Power-BI-Gateway-Monitoring-amp-Administrating-Part-...

 

Hope it helps for you.

Thank you for you suggestion.
But I think it wouldn't do in my case.

My target is to have a single connector file, which would be easy for users of our API to add to there PowerBi datasources. And, at least at the moment, without using PowerBI server side (not sure if I'm correct if it's used in your approach with gateway).

So your solution would be a bit too complex for target users as, they would need to do a lot of configuration on there local to use the API. 
With connector the approach seems very clear and simple to me as:
Target users would:
1. Dowload our connector into custom connectors
2. Allow unsafe connectors for usage
3. Use connector to retrive data from API with inputing any credencials and filters directly in PowerBI in user-friendly windows 🙂

Hi @meyron 

 

Agreed I thought that this is only for a single user and I'm not aware of that you are planning to develop this for a set of users. Yes as per you my approach is difficult in case of more users.

 

Custom connectors will be a good choice, so that all your end users won't need anything to worry about.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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