# DownloadFile

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.HTTP/tree/main/Frends.HTTP.DownloadFile>

{% tabs %}
{% tab title="Parameter: Input" %}

| Name                 | Description                                                                                                                                                                                                                    |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Url : `String`       | <p>The URL with protocol and path.</p><p>You can include query parameters directly in the URL.</p><p><br>Default: <code><https://example.org/path/to></code><br>Example: <code><https://example.org/path/to></code></p>        |
| Headers : `Header[]` | <p>List of HTTP headers to be added to the request.</p><p><br>Default: <code>-</code><br>Example: <code>\[ { Name = "Content-Type", Value = "application/json" }, { Name = "Accept", Value = "application/json" } ]</code></p> |
| FilePath : `String`  | <p>Exact location and name of the file to be created.</p><p><br>Default: <code>-</code><br>Example: <code>C:\temp\example.txt</code></p>                                                                                       |
| {% endtab %}         |                                                                                                                                                                                                                                |

{% tab title="Parameter: Options" %}

| Name                                                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Authentication : `Authentication`                     | <p>Method of authenticating request.</p><p>Possible values:</p><ul><li><code>None</code>:</li></ul><p>Method of authenticating request.</p><ul><li><code>Basic</code>:</li></ul><p>Method of authenticating request.</p><ul><li><code>WindowsAuthentication</code>:</li></ul><p>Method of authenticating request.</p><ul><li><code>WindowsIntegratedSecurity</code>:</li></ul><p>Method of authenticating request.</p><ul><li><code>OAuth</code>:</li></ul><p>Method of authenticating request.</p><ul><li><code>ClientCertificate</code>:</li></ul><p>Method of authenticating request.</p><p><br>Default: <code>-</code><br>Example: <code>OAuth</code></p> |
| Username : `String`                                   | <p>If WindowsAuthentication is selected you should use domain\username</p><p><br>Default: <code>-</code><br>Example: <code>Username</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| 🗝Password : `String`                                 | <p>Password for the user</p><p><br>Default: <code>-</code><br>Example: <code>Password123</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| 🗝Token : `String`                                    | <p>Bearer token to be used for request.</p><p>Token will be added as Authorization header.</p><p><br>Default: <code>-</code><br>Example: <code>Token123</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ClientCertificateSource : `CertificateSource`         | <p>Specifies where the Client Certificate should be loaded from.</p><p>Possible values:</p><ul><li><code>CertificateStore</code>:</li></ul><p>Specifies where the Client Certificate should be loaded from.</p><ul><li><code>File</code>:</li></ul><p>Specifies where the Client Certificate should be loaded from.</p><ul><li><code>String</code>:</li></ul><p>Specifies where the Client Certificate should be loaded from.</p><p><br>Default: <code>0</code><br>Example: <code>File</code></p>                                                                                                                                                             |
| ClientCertificateFilePath : `String`                  | <p>Applicable only when Certificate Source is "File".</p><p>Path to the Client Certificate, pfx (pkcs12) files are recommended. For other supported formats, see</p><p><https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.x509certificates.x509certificate2collection.import?view=netframework-4.7.1></p><p><br>Default: <code>-</code><br>Example: <code>domain\path</code></p>                                                                                                                                                                                                                                                       |
| ClientCertificateInBase64 : `String`                  | <p>Applicable only when Certificate Source is "String".</p><p>Client certificate bytes as a base64 encoded string, pfx (pkcs12) format is recommended. For other supported formats, see</p><p><https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.x509certificates.x509certificate2collection.import?view=netframework-4.7.1></p><p><br>Default: <code>-</code><br>Example: <code>domain\path</code></p>                                                                                                                                                                                                                                |
| 🗝ClientCertificateKeyPhrase : `String`               | <p>Applicable only when Certificate Source is "File" or "String".</p><p>Key phrase (password) to access the certificate data</p><p><br>Default: <code>-</code><br>Example: <code>string value</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| CertificateThumbprint : `String`                      | <p>Applicable only when Certificate Source is "CertificateStore".</p><p>Thumbprint for using client certificate authentication.</p><p><br>Default: <code>-</code><br>Example: <code>thumbprint</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| CertificateStoreLocation : `CertificateStoreLocation` | <p>Applicable only when Certificate Source is "CertificateStore".</p><p>Store location for the certificate.</p><p>Possible values:</p><ul><li><code>CurrentUser</code>:</li></ul><p>Applicable only when Certificate Source is "CertificateStore".</p><p>Store location for the certificate.</p><ul><li><code>LocalMachine</code>:</li></ul><p>Applicable only when Certificate Source is "CertificateStore".</p><p>Store location for the certificate.</p><p><br>Default: <code>0</code><br>Example: <code>CurrentUser</code></p>                                                                                                                            |
| LoadEntireChainForCertificate : `Boolean`             | <p>Should the entire certificate chain be loaded from the certificate store and included in the request. Only valid when using Certificate Store as the Certificate Source</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                             |
| ConnectionTimeoutSeconds : `Int32`                    | <p>Timeout in seconds to be used for the connection and operation.</p><p><br>Default: <code>30</code><br>Example: <code>30</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| FollowRedirects : `Boolean`                           | <p>If FollowRedirects is set to false, all responses with an HTTP status code from 300 to 399 is returned to the application.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| AllowInvalidCertificate : `Boolean`                   | <p>Do not throw an exception on certificate error.</p><p><br>Default: <code>-</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| AllowInvalidResponseContentTypeCharSet : `Boolean`    | <p>Some Api's return faulty content-type charset header. This setting overrides the returned charset.</p><p><br>Default: <code>-</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ThrowExceptionOnErrorResponse : `Boolean`             | <p>Throw exception if return code of request is not successfull</p><p><br>Default: <code>-</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| AutomaticCookieHandling : `Boolean`                   | <p>If set to false, cookies must be handled manually. Defaults to true.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| Overwrite : `Boolean`                                 | <p>If set to true, an existing file at the target path will be overwritten during download.</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| {% endtab %}                                          |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |

{% tab title="Result: Result" %}

| Name                | Description                                                       |
| ------------------- | ----------------------------------------------------------------- |
| Success : `Boolean` | <p>Task complete.<br>Example: <code>True</code></p>               |
| FilePath : `String` | <p>Path to created file.<br>Example: <code>C:\temp.txt</code></p> |
| {% endtab %}        |                                                                   |

{% tab title="Changelog" %}

## Changelog

### \[1.4.0] - 2026-03-02

#### Added

* Added CertificateStoreLocation option to allow selection between CurrentUser and LocalMachine certificate stores when using certificate authentication.

### \[1.3.0] - 2025-05-15

#### Changed

* Added new Overwrite parameter to control whether the downloaded file should replace an existing one.
* Use the default parameter value ('false') if you want the task to work as before.

### \[1.2.0] - 2025-03-25

#### Changed

* Update packages: System.Runtime.Caching 7.0.0 -> 9.0.3 coverlet.collector 3.1.0 -> 6.0.4 Microsoft.NET.Test.Sdk 16.7.0 -> 17.13.0 MSTest.TestAdapter 2.1.2 -> 3.8.3 MSTest.TestFramework 2.1.2 -> 3.8.3

### \[1.1.0] - 2024-12-30

#### Changed

* Descriptions of ClientCertificate suboptions includes clearer information about usage in terms of different types of ClientCertificate.

### \[1.0.0] - 2023-01-27

#### Added

* Initial implementation.
  {% endtab %}
  {% endtabs %}
