Web.DefaultProxy

Updated on

Web.DefaultProxy is a Power Query M function that retrieves the system’s default proxy settings used for HTTP requests.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Web.DefaultProxy( uri as text ) as nullable record

Examples

Let’s look at an example that uses Web.DefaultProxy:

UseWebDefaultProxyOption = options[UseWebDefaultProxy]?,
ProxyUriRecord = if UseWebDefaultProxyOption then Web.DefaultProxy(Host) else null,
ProxyOptions = if Record.FieldCount(ProxyUriRecord) > 0 then
      [
            Proxy = ProxyUriRecord[ProxyUri]
      ]
      else [],
      ...

This code snippet is setting up proxy options for web requests based on user-defined settings. Here’s what it does in simple terms:

  1. Checks User Settings: It looks at the options[UseWebDefaultProxy] setting to determine if the default web proxy should be used.
  2. Gets Proxy Information: If the default proxy is enabled, it retrieves the proxy details using Web.DefaultProxy(Host).
  3. Parses Proxy Details: If a proxy is found, the Uri.Parts function is used to break down the proxy’s details (like its scheme, host, and port).
  4. Configures Proxy Options: If the proxy details are valid, it builds a record containing the proxy host and port. If no proxy is being used, it leaves the options empty.

In short, this setup dynamically determines whether to use a proxy and gathers the necessary details to configure it for web requests.

Learn more about Web.DefaultProxy in the following articles:

Other functions related to Web.DefaultProxy are:

Contribute » | Contributors: Rick de Groot

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy