# Attachments

### Add attached file (from bytes)

Upload a file as an attachment to task item.

#### Parameters <a href="#parameters" id="parameters"></a>

| Parameter       | Description                              |
| --------------- | ---------------------------------------- |
| Task app name   | Name of Task app in SharePoint (not id)  |
| Task ID         | ID of task                               |
| Remote filename | Remote filename                          |
| Source bytes    | Table (consisting of bytes) to read from |

#### Output <a href="#output" id="output"></a>

Record with information about whether operation failed or not.

| Member       | Description                                                            |
| ------------ | ---------------------------------------------------------------------- |
| HasFailed    | Whether operation has failed or not                                    |
| ErrorMessage | A description of the failure, if any                                   |
| ErrorCode    | An error code related to operation failure. Is 0 if no failure occured |

#### Errors <a href="#errors" id="errors"></a>

| Error code | Description                                  |
| ---------- | -------------------------------------------- |
| 1000       | Unspecified error.                           |
| 1000001    | User is not authorized to perform operation. |
| 1000004    | Item with given id does not exist.           |

### Add attached file (from file system) <a href="#add-attached-file-from-file-system" id="add-attached-file-from-file-system"></a>

Upload a file as an attachment to task item.

#### Parameters <a href="#parameters" id="parameters"></a>

| Parameter       | Description                                                                                                            |
| --------------- | ---------------------------------------------------------------------------------------------------------------------- |
| Task app name   | Name of Task app in SharePoint (not id)                                                                                |
| Task ID         | ID of task                                                                                                             |
| Remote filename | Remote filename                                                                                                        |
| Local filename  | Full path to file to upload. Note that the user the application pool running Flow Server must have access to the file. |

#### Output <a href="#output" id="output"></a>

Record with information about whether operation failed or not.

| Member       | Description                                                            |
| ------------ | ---------------------------------------------------------------------- |
| HasFailed    | Whether operation has failed or not                                    |
| ErrorMessage | A description of the failure, if any                                   |
| ErrorCode    | An error code related to operation failure. Is 0 if no failure occured |

#### Errors <a href="#errors" id="errors"></a>

| Error code | Description                                  |
| ---------- | -------------------------------------------- |
| 1000       | Unspecified error.                           |
| 1000001    | User is not authorized to perform operation. |
| 1000004    | Item with given id does not exist.           |

### Add attached file (from stream) <a href="#add-attached-file-from-stream" id="add-attached-file-from-stream"></a>

Upload a file as an attachment to task item.

#### Parameters <a href="#parameters" id="parameters"></a>

| Parameter     | Description                             |
| ------------- | --------------------------------------- |
| Task app name | Name of Task app in SharePoint (not id) |
| Task ID       | ID of task                              |
| Filename      | Remote filename                         |
| Source stream | Simple variable containg a stream       |

#### Output <a href="#output" id="output"></a>

Record with information about whether operation failed or not.

| Member       | Description                                                            |
| ------------ | ---------------------------------------------------------------------- |
| HasFailed    | Whether operation has failed or not                                    |
| ErrorMessage | A description of the failure, if any                                   |
| ErrorCode    | An error code related to operation failure. Is 0 if no failure occured |

#### Errors <a href="#errors" id="errors"></a>

| Error code | Description                                  |
| ---------- | -------------------------------------------- |
| 1000       | Unspecified error.                           |
| 1000001    | User is not authorized to perform operation. |
| 1000004    | Item with given id does not exist.           |

### Delete all attached files <a href="#delete-all-attached-files" id="delete-all-attached-files"></a>

Delete all attachments on provided task item.

#### Parameters <a href="#parameters" id="parameters"></a>

| Parameter     | Description                             |
| ------------- | --------------------------------------- |
| Task app name | Name of Task app in SharePoint (not id) |
| Task ID       | ID of task                              |
| Filename      | Remote filename                         |

#### Output <a href="#output" id="output"></a>

Record with information about whether operation failed or not.

| Member       | Description                                                            |
| ------------ | ---------------------------------------------------------------------- |
| HasFailed    | Whether operation has failed or not                                    |
| ErrorMessage | A description of the failure, if any                                   |
| ErrorCode    | An error code related to operation failure. Is 0 if no failure occured |

#### Errors <a href="#errors" id="errors"></a>

| Error code | Description                                  |
| ---------- | -------------------------------------------- |
| 1000       | Unspecified error.                           |
| 1000001    | User is not authorized to perform operation. |
| 1000004    | Item with given id does not exist.           |

### Delete attached file <a href="#delete-attached-file" id="delete-attached-file"></a>

Delete an attachment on provided task item.

#### Parameters <a href="#parameters" id="parameters"></a>

| Parameter     | Description                             |
| ------------- | --------------------------------------- |
| Task app name | Name of Task app in SharePoint (not id) |
| Task ID       | ID of task                              |
| Filename      | Remote filename                         |

#### Output <a href="#output" id="output"></a>

Record with information about whether operation failed or not.

| Member       | Description                                                            |
| ------------ | ---------------------------------------------------------------------- |
| HasFailed    | Whether operation has failed or not                                    |
| ErrorMessage | A description of the failure, if any                                   |
| ErrorCode    | An error code related to operation failure. Is 0 if no failure occured |

#### Errors <a href="#errors" id="errors"></a>

| Error code | Description                                  |
| ---------- | -------------------------------------------- |
| 1000       | Unspecified error.                           |
| 1000001    | User is not authorized to perform operation. |
| 1000004    | Item with given id does not exist.           |
| 1000005    | File not found.                              |

### List attached files <a href="#list-attached-files" id="list-attached-files"></a>

Lists all files attached to specified task item.

#### Parameters <a href="#parameters" id="parameters"></a>

| Parameter     | Description                             |
| ------------- | --------------------------------------- |
| Task app name | Name of Task app in SharePoint (not id) |
| Task ID       | ID of task                              |

#### Output <a href="#output" id="output"></a>

Record with information about whether operation failed or not. If succesful, result of operation is stored in Results member

| Member       | Description                                                            |
| ------------ | ---------------------------------------------------------------------- |
| HasFailed    | Whether operation has failed or not                                    |
| ErrorMessage | A description of the failure, if any                                   |
| ErrorCode    | An error code related to operation failure. Is 0 if no failure occured |
| Results      | Table variable containing the results of operation                     |

Structure of Results Results

&#x20;Filename

&#x20;ServerRelativeUrl

#### Errors <a href="#errors" id="errors"></a>

| Error code | Description                                  |
| ---------- | -------------------------------------------- |
| 1000       | Unspecified error.                           |
| 1000001    | User is not authorized to perform operation. |
| 1000004    | Item with given id does not exist.           |
