Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
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"
Solved! Go to Solution.
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?
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.
let
Source = Web.BrowserContents("https://www.ship24.com/tracking",[Query= [p = TrackingID]])
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
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:
Hi @pankajj
Is "3407985361" the TrackingID in your code? Do you want to get HTML table from web?
Based on my test, if you want to get the HTML table from web, you need to use Web.BroswerContents() which returns html, Web.Contents() will return a binary result.
If you nest Html.table() outside Web.Contents(), you will always get an empty table whatever your web address.
When you use the web connector to extract data, you would find that it also use Web.BroswerContents() instead of Web.Contents().
In addition, about Dynamic data source using Web.contents, you can refer: Dynamic Web.Contents() and Power BI Refresh Errors
Here is a blog with similar issue like yours, I hope it could help you.
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.
Thanks so much for your help. I will try your method.
I am able to get the data using Web.BrowserContents in Power BI Desktop but not in Power BI Service.
Can you suggest, how to edit the following query to make it refreshable in Power BI Service to get the same result using Tracking ID : 3407985361
I am expecting, following result:
Looking forward to hearing from you.
Thanks so much for your help.
Best regards,
Pankajj
The service seems to be malfunctioning at the moment - I get a 500 error when querying by that ID.
Please find below a link to the Power BI file. I am not getting any error with the function fxtracking.
Hoping, you would be able to help in editing the query by using RelativePath, Query and replacing Html.Table to let it refresh automatically. without the below error.
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?
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.
Is there any workaround for this problem?
I kept looking for a solution but did not find anyone answering a similar Shipment Tracking webquery.
Will really appreciate your kind help on the subject.
Thanks a ton,
Pankajj
User | Count |
---|---|
101 | |
69 | |
58 | |
47 | |
47 |