Forum Discussion
Web.Contents - How to Parse Non-Standard URL component into Optional Query Parameter
To the PBI Community,
I'm in the process of resolving issues from dynamic URL sources in my PBIX file so that I can schedule dataset refreshes in the service. In order to do that it's been described that one must break up the base URL which has to be retrievalble on its own and the dynamic portion and encode that using either the optional "Query" or "Relative Path" option in the Web.Contents function. Here is an example of the URL I need to break up and reconstitute:
the base URL being: https://api4.successfactors.com:443/odata/v2/FODepartment
and the dynamic part being: (externalCode='000010',startDate=datetime'2022-07-01T00:00:00')/cust_toDivision
I have not had luck getting the full URL reconstituted because, at least I suspect, that using the Relative Path parameter results in a "/" being inserted after the base URL, before the dynamic portion is added. Essentially resulting in this:
https://api4.successfactors.com:443/odata/v2/FODepartment/(externalCode='000010',startDate=datetime'2022-07-01T00:00:00')/cust_toDivision
This will generate a 500 / 404 error when testing in Postman.
alternatively utilizing the Query parameter results in a "?" being added at the end of the base URL which makes the API interpret the first statement as "(externalCode" = '000010',startDate ...." and essentially, since this is not an expected API parameter, the API ignores that part and just replies based on the base URL, essentially responding with a full table of departments.
I'm using Fiddler to monitor the HTTPS requests going out to the API, but there is some guess work as well. I'm not entirely sure if the Power Query internal tracing functionality could be used here to test different uses of the syntax to see how different variations of the Web.Contents function would be parsed by the query editor into the full URL. Maybe somebody could point me to a useful debugging tool for M code?
Either way, is it possible to make this work with Web.Contents? I really need this (and other) datasets from this datasource to be able to do schedule based updates in the PBI service.
Many thanks for your time and feedback,
Henrik
Hi waeltken
Did you try using below part as the base URL and treat the remaining part as relative path?
Best Regards,
Community Support Team _ Jing
2 Replies
- waeltkenHelper I
Hi Jing,
I was able to resolve using the following as base:
https://api4.successfactors.com:443/odata/v2
This URL returns the overall list of active properties when testing in Postman and is viable on its own. The rest of the URL can be parsed with the RelativePath and Query parameters of the Web.Contents function.
Thanks,
Henrik
- v-jingzhangCommunity Support
Hi waeltken
Did you try using below part as the base URL and treat the remaining part as relative path?
Best Regards,
Community Support Team _ Jing