Forum Discussion

pankajj's avatar
pankajj
Helper III
4 years ago
Solved

Web.BrowserContents Refresh Error Power BI Services

Greetings PBI Experts!

 

I am using the following query to extract shipping data. It works fine on the Desktop version but not on Power BI services.

 

Can someone please advise how to change this code to use Query or Relative Path? 

 

= (TrackingID as text)=>

let
Source = Web.BrowserContents("https://www.ship24.com/tracking?p=" & TrackingID),
#"Extracted Table From Html" = Html.Table(Source, {{"TrackingID", ".md\:text-2xl"}, {"Status", ".md\:w-34pc"}, {"Courier", "APP-USER-COURIER-LABEL"}, {"Origin", ".j-sh:nth-child(1)"}, {"Destination", ".j-sh:nth-child(3)"}, {"Delivered on", ".capitalize"}}, [RowSelector="USER-PARCEL-CARD"])
in
#"Extracted Table From Html"

 

 

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi pankajj 

    Your table is based on query and it is a dynamic data source. If I add ID in code directly, it seems that we could refresh this report with gateway in Power BI. Try to use parameter to get dynamic tracking id. You can add all ids you need in parameter list, and you can change the id you get by parameter in Desktop and Service.

    let
    Source = Web.BrowserContents("https://www.ship24.com/tracking?p=" & #"Tracking ID"),
    #"Extracted Table From Html" = Html.Table(Source, {{"TrackingID", ".md\:text-2xl"}, {"Status", ".md\:w-34pc"}, {"Courier", "APP-USER-COURIER-LABEL"}, {"Origin", ".j-sh:nth-child(1)"}, {"Destination", ".j-sh:nth-child(3)"}, {"Delivered on", ".capitalize"}}, [RowSelector="USER-PARCEL-CARD"])
    in
    #"Extracted Table From Html"

    Then download a gateway and configure the credential. Then you can schedule refresh your report.

    For reference: 

    What is an on-premises data gateway?

    Configure scheduled refresh

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

9 Replies

    • pankajj's avatar
      pankajj
      Helper III

      lbendlin 

       

      Thank you very much for your help.

       

      Web.BrowserContents does not refresh in the Power BI Service.

       

      I replace it with Web.Contents, it works but it shows empty table on Invoked Function.

       

      Please try this with sample tracking id: 3407985361.

       

      I believe the error is due to the subsequent steps:

       

      #"Extracted Table From Html" = Html.Table(Source, {{"TrackingID", ".md\:text-2xl"}, {"Status", ".md\:w-34pc"}, {"Courier", "APP-USER-COURIER-LABEL"}, {"Origin", ".j-sh:nth-child(1)"}, {"Destination", ".j-sh:nth-child(3)"}, {"Delivered on", ".capitalize"}}, [RowSelector="USER-PARCEL-CARD"])
      in
      #"Extracted Table From Html"

       

      Kindly check.

       

      Thanks a ton.

       

      Best regards,

       

      Pankajj

      • pankajj's avatar
        pankajj
        Helper III

        Greg_Deckler 

        Can you please help.

         

        I have tried using the M code as:

         

        (TrackingID as text) =>

        let
        Source = Web.Contents(

        "https://www.ship24.com/",

        [ RelativePath= "tracking",

        Query= [p = TrackingID]]),


        Result = List.Transform(TrackingID, each TrackingID(_)),

        #"Converted to Table1" = Table.FromList(Result,

        {{"TrackingID", ".md\:text-2xl"}, {"Status", ".md\:w-34pc"}, {"Courier", "APP-USER-COURIER-LABEL"},
        {"Origin", ".j-sh:nth-child(1)"}, {"Destination", ".j-sh:nth-child(3)"}, {"Delivered on", ".capitalize"}}, [RowSelector="USER-PARCEL-CARD"])


        in

        #"Converted to Table1"

         

        but with Invoked Function, getting the following Error:

         

        An error occurred in the ‘’ query. Expression.Error: We cannot convert the value "3407985361" to type List.
        Details:
        Value=3407985361
        Type=[Type]
         
        Thank you in advance for your help as always.
         
        Best regards,
         
        Pankajj