Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Scheduled refresh Post call with Web.Contents doesn't work

Hi everyone,

-- See EDIT at the end of the post. Maybe this has to do with a 303 response?

The community has helped me alot lately. Hopefully someone has a solution/answer/explanation for the following problem.

I'm retrieving data from a server by means of a post call with Web.Contents. This works perfectly fine in power BI desktop, no issues at all.

However, when I publish the report to the report server and try to refresh the data an error occurs: "Unable to connect to the remote server".

 

This is my M power query (works fine in Power BI desktop):

 

 

 

 

let
  url = "[aWebsite]",
  auth_key = "Basic [key]",
  header = [#"Authorization"=auth_key, #"Content-Type"="application/x-www-form-urlencoded"],
  body = "login=XXXXX&password=XXXXX&mpoint=-1&start_date=2021-11-01&end_date=&methode=nochoice&preparation_category=-1&prepared_by=-1&product_description=",
  Source =  Csv.Document(Web.Contents(url, [RelativePath="export/download",Headers=header,Content=Text.ToBinary(body)]),[Delimiter=";"]),
  #"PromoteHeaders" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
  #"Change type" = Table.TransformColumnTypes(#"PromoteHeaders",{{"Werk-/achtergrondruimte", type text}, {"methode", type text}, {"Nummer monster", type text}, {"Datum bereiding", type date}, {"Bereider/Aantal mdw.", type text}, {"Productomschrijving", type text}, {"Categorie bereiding", type text}, {"chargenummer", type text}, {"Tijd open (min.)", Int64.Type}, {"Waarde 3 dg", type text}, {"Waarde 7 dg", Int64.Type}, {"Laatst aangepast door", type text}, {"Micro-organisme", type text}, {"Soort materiaal gedesinfecteerd", type text}, {"Opmerking", type text}})

in 
 #"Change type"

 

 

 

 

As you can see, I tried a solution with RelativePath as suggested by some other users. However, the report server still can't manage to establish a connection.

 

Thank you for help!

 

EDIT:

 

Maybe this could be part of the problem? When I want to retrieve data from the server a url like: foo.bar.com/export/download is used. In my solution i used url = "foo.bar.com" and RelativePath = "/export/download".

However when I reach foo.bar.com the address is redirected to foo.bar.com/@@login?camefrom=%2F%40%40index (see screenshot below). Maybe Power BI can't evaluate foo.bar.com in a static way because it should validate foo.bar.com/@@login?camefrom=%2F%40%40index? However, when retrieving data the "@@login?camefrom=%2F%40%40index" should not be used. How can I trick Power BI to do so?

 

 

 

7 Replies