---
category: [Administration & Integrations, Administration & Integrations/Workday API, Platform and Product Extensions, Platform and Product Extensions/Integration]
nav: wcp_docs
parent_url: /wcp_docs/
title: >- 
  Concept: Workday REST API File Attachments
layout: subsection
---

<a id="section_aph_mtm_bsb"></a>
Several Workday REST services provide POST endpoints that enable you to attach files to business objects. These POST endpoints support `multipart/form-data` requests containing both file attachment and metadata. The form-data request body depends on whether the POST endpoint creates the file attachment on an existing or new business object.

## <a id="section_nkr_ptm_bsb"></a>Endpoints That Create an Attachment on an Existing Business Object

Some Workday REST services provide POST endpoints with the `attachments` subresource on a specific business object. These attachment endpoints attach a file to an existing business object and typically require only the file attachment in the request body.

Examples:

<table><thead><tr><th>REST Service</th><th>Attachments Endpoint</th></tr></thead><tbody><tr><td>Accounts Payable</td><td>POST /supplierInvoiceRequests/{ID}/attachments</td></tr><tr><td>Expense</td><td>POST /entries/{ID}/attachments</td></tr><tr><td>Procurement</td><td>POST /requisitions/{ID}/attachments</td></tr><tr><td>Recruiting</td><td>POST /prospects/{ID}/resumeAttachments</td></tr></tbody></table><br/>

To submit a POST endpoint that creates an attachment to an existing business object:

1.  Set the `Content-Type` HTTP header to `multipart/form-data`.
2.  Specify the ID of the existing business object as a path parameter.
3.  In the request body, specify `form-data`, and add:

<table><thead><tr><th>Key</th><th>Value</th></tr></thead><tbody><tr><td><code>attachmentContent</code></td><td><p>The file attachment and location.</p></td></tr></tbody></table><br/>



<b>Sample request using Postman</b>

POST endpoint:

```
POST https://{hostname}/api/procurement/v3/{tenant}/requisitions/{requisitionId}/attachments
```

HTTP header:

```
Content-Type: multipart/form-data
```

`form-data` body:

```
Key: attachmentContent
Value: {selectedFile}
```

In Postman, select <b>File</b> on the `attachmentContent` key, and select the file attachment on the `attachmentContent` value.

<b>Sample curl request</b>

```
curl --location --request POST 'https://{hostname}/api/procurement/v3/{tenant}/requisitions/{requisitionId}/attachments' \
--header 'Authorization: bearer 74hkgmmqb01pqfw7qkjy1lgd1' \
--header 'Content-Type: multipart/form-data' \
--form 'attachmentContent=@"/C:/temp/sampleFile.txt"'
```

<b>Sample response</b>

```
{
    "id": "9c3e89353ef4010023f8b71b1a6c0000",
    "descriptor": "sampleFile.txt",
    "contentType": {
        "descriptor": "text/plain - mime_plain",
        "id": "d9ae6950446c11de98360015c5e6daf6"
    },
    "fileLength": 845,
    "fileName": "sampleFile.txt"
}
```

## <a id="section_o2j_j5m_bsb"></a>Endpoints That Create Attachments with a New Business Object

Some Workday REST services provide POST endpoints that create a business object with file attachments.

Examples:

<table><thead><tr><th>REST Service</th><th>Attachments Endpoint</th></tr></thead><tbody><tr><td>Request</td><td>POST /requests</td></tr><tr><td>Staffing</td><td>POST /workers/{ID}/checkInTopics</td></tr></tbody></table><br/>

In addition to the request fields for the new business object, the request body for these POST endpoints includes file attachments. Example: The request body of the `POST /requests` endpoint includes `questionnaireAttachments`:

```
{
. . .
"questionnaireAnswers": [
  {
    "questionnaireAttachments": [
      {
        "fileName": "string": {
           "id": "string",
          "descriptor": "string",
          "href": "string"
        },
        "fileLength": 0,
        "id": "string",
        "descriptor": "string"
      }
    ],
    . . .
  }
],
. . .
}

```

To submit a POST endpoint that creates a new business object with file attachments:

1.  Set the `Content-Type` HTTP header to `multipart/form-data`.
2.  In the request body, specify `form-data`, and add:

<table><thead><tr><th>Key</th><th>Value</th></tr></thead><tbody><tr><td><i>file1</i></td><td><p>The file attachment and location.</p> <p>You can use any name as the <i>file1</i> key.</p> <p>If the POST endpoint supports multiple attachments in an array, you can add another file key. Example: <i>file2</i>.</p></td></tr><tr><td><code>jsonData</code></td><td><p>The JSON request body that specifies the request fields for the new business object.</p> <p>In the attachment portion of the JSON request body, specify <code>"file": "cid:file1"</code>. Example:</p>    ```
"questionnaireAttachments": [
  { "file": "cid:file1" } 
]
    ```

 <p>If you used a different <i>file1</i> key name, replace <i>file1</i> in <code>cid:file1</code> with the appropriate file key.</p> <p>If you specified multiple file keys, add the corresponding file items in the array. Example:</p>    ```
"questionnaireAttachments": [
  { "file": "cid:file1" },
  { "file": "cid:file2" }
]
    ```

</td></tr></tbody></table><br/>



<b>Sample request using Postman</b>

POST endpoint:

```
POST https://{hostname}/request/v1/{tenant}/requests
```

HTTP header:

```
Content-Type: multipart/form-data
```

`form-data` body:

```
Key: file1
Value: {selectedFile}
```

```
Key: jsonData
Value: {
    "comment": "Please review.",
    "description": "Review request",
    "requestType":{
        "id": "8aae3f174909012f50f2ff5e505f5a09"
    },
    "questionnaireResponses": {
        "questionnaireAnswers": [
            {
                "answerNumeric": 10,
                "questionItem": {
                    "id": "8aae3f174909011301757039505f4d09"
                },
                "questionnaireAttachments": [
                    {
                        "file": "cid:file1"
                    } 
                ]
            }
        ]
    }
}
```

In Postman, select <b>File</b> on the <i>file1</i> key, and select the file attachment on the <i>file1</i> value.

<b>Sample curl request</b>

```
curl --location --request POST 'https://{hostname}/api/request/v1/{tenant}/requests' \
--header 'Content-Type: multipart/form-data' \
--header 'Authorization: Bearer 74hkgmmqb01pqfw7qkjy1lgd1' \
--form 'file1=@"/C:/temp/sampleDocument.txt"' \
--form 'jsonData="{
    \"comment\": \"Please review.\",
    \"description\": \"Review request\",
    \"requestType\":{
        \"id\": \"8aae3f174909012f50f2ff5e505f5a09\"
    },
    \"questionnaireResponses\": {
        \"questionnaireAnswers\": [
            {
                \"answerNumeric\": 10,
                \"questionItem\": {
                    \"id\": \"8aae3f174909011301757039505f4d09\"
                },
                \"questionnaireAttachments\": [
                    {
                        \"file\": \"cid:file1\"
                    } 
                ]
            }
        ]
    }
}"'
```

<b>Sample response</b>

```
{
    "id": "9c3e89353ef481002d261f298a220000",
    "descriptor": "Request : Rest API Request Type : Logan McNeil (CHRO, HRExe, Mgr 4000, MatMgr, ProMgr,TalMgr,VPRept)",
    "questionnaireResponses": {
        "id": "9c3e89353ef481002d261f298a220002",
        "descriptor": "Response for Request Rest API Questionnaire",
        "questionnaireAnswers": [
            {
                "id": "9c3e89353ef481002d261f298a220003",
                "descriptor": "10",
                "answerNumeric": 10,
                "questionItem": {
                    "descriptor": "How old are you? for Request Rest API Questionnaire",
                    "id": "8aae3f174909011301757039505f4d09"
                },
                "questionnaireAttachments": [
                    {
                        "id": "9c3e89353ef401002d261fc32d010000",
                        "descriptor": "sampleDocument.txt",
                        "fileLength": 4,
                        "contentType": {
                            "descriptor": "text/plain - mime_plain",
                            "id": "d9ae6950446c11de98360015c5e6daf6"
                        },
                        "fileName": "sampleDocument.txt"
                    }
                ]
            }
        ]
    },
    "requestType": {
        "descriptor": "Rest API Request Type",
        "id": "8aae3f174909012f50f2ff5e505f5a09"
    },
    "description": "Review request",
    "comment": "Please review."
}
```

