# Get Documents of a Set

Endpoint Name: `URL/access/klearstack/getdocumentsforset`

Request type : `POST`

Authorization: Bearer token as header

Endpoint Details: The `getdocumentsforset`endpoint will be used to fetch all the documents belonging to a certain set based on the Set Reference Number.

<table data-header-hidden><thead><tr><th width="124"></th><th></th></tr></thead><tbody><tr><td>Method</td><td>URL</td></tr><tr><td>POST</td><td><code>URL/access/klearstack/getdocumentsforset</code>   </td></tr></tbody></table>

### Request Body

<table data-header-hidden><thead><tr><th width="223"></th><th width="97"></th><th></th></tr></thead><tbody><tr><td>Params</td><td>Values</td><td>Description</td></tr><tr><td>company_name</td><td>string</td><td>Name of the company for which the user is logging in</td></tr><tr><td>username</td><td>string</td><td>User Name</td></tr><tr><td>set_reference_number</td><td>string </td><td>set_reference_number for which documents are required</td></tr><tr><td>role</td><td>string</td><td>user role, e.g:Approver</td></tr></tbody></table>

### Shell (cURL)

* Request Body

```sh
curl --location POST "URL/access/klearstack/getdocumentsforset" \
  --header "Authorization: Bearer your_token_here" \
  --form "company_name=Replace_Company_Name_Here" \
  --form "username=Replace_Username_Here" \
  --form "set_reference_number=Replace_Set_Reference_Number_Here" \
  --form "role=Replace_Role_Here"
```

### Python

* Request Body

```python
import requests

# API URL
url = "URL/access/klearstack/getdocumentsforset"

# Request payload
data = {
    "company_name": "Replace_Company_Name_Here",
    "username": "Replace_Username_Here",
    "set_reference_number": "Replace_Set_Reference_Number_Here",
    "role": "Replace_Role_Here"
}

# Headers
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer your_token_here"
}

# Make the POST request
response = requests.post(url, json=data, headers=headers)

# Print the response
if response.status_code == 200:
    print(response.json())
else:
    print("Error:", response.text)
```

### Java

* Request Body

```java
import okhttp3.*;

import java.io.IOException;

public class GetDocumentsForSetAPI {
    public static void main(String[] args) {
        OkHttpClient client = new OkHttpClient();

        // JSON payload
        String jsonPayload = "{ \"company_name\": \"Replace_Company_Name_Here\", " +
                "\"username\": \"Replace_Username_Here\", " +
                "\"set_reference_number\": \"Replace_Set_Reference_Number_Here\", " +
                "\"role\": \"Replace_Role_Here\" }";

        RequestBody body = RequestBody.create(
            jsonPayload, MediaType.parse("application/json"));

        Request request = new Request.Builder()
            .url("URL/access/klearstack/getdocumentsforset")
            .post(body)
            .addHeader("Content-Type", "application/json")
            .addHeader("Authorization", "Bearer your_token_here")
            .build();

        try (Response response = client.newCall(request).execute()) {
            if (response.isSuccessful()) {
                System.out.println("Response: " + response.body().string());
            } else {
                System.out.println("Error: " + response.body().string());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
```

### Node.js

* Request Body

```javascript
var request = require('request');

const payload = {
  "company_name": "Replace_Company_Name_Here",
  "username": "Replace_Username_Here",
  "set_reference_number": "Replace_Set_Reference_Number_Here",
  "role": "Replace_Role_Here"
};

const options = {
  url: 'URL/access/klearstack/getdocumentsforset',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your_token_here'
  },
  json: payload
};

request.post(options, function(err, httpResponse, body) {
  if (err) {
    console.error('Request failed:', err);
    return;
  }

  console.log('Response:', body);
});
```

### JavaScript (XMLHttpRequest)

* Request Body

```javascript
var payload = JSON.stringify({
    company_name: "Replace_Company_Name_Here",
    username: "Replace_Username_Here",
    set_reference_number: "Replace_Set_Reference_Number_Here",
    role: "Replace_Role_Here"
});

var xhr = new XMLHttpRequest();
xhr.open("POST", "URL/access/klearstack/getdocumentsforset", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer your_token_here");

// Handle response
xhr.onreadystatechange = function () {
    if (xhr.readyState === XMLHttpRequest.DONE) {
        if (xhr.status === 200) {
            console.log("Response:", xhr.responseText);
        } else {
            console.error("Error:", xhr.responseText);
        }
    }
};

xhr.send(payload);
```

### API Response

<table data-header-hidden><thead><tr><th width="146"></th><th></th></tr></thead><tbody><tr><td>Status code</td><td>Example Response</td></tr><tr><td>200</td><td><p></p><pre class="language-json"><code class="lang-json">{
    "all_result": [
        {
            "batch_id": "f383919b-8efe-4014-a725",
            "status": "complete",
            "file_name": "test.pdf",
            "ondisk_encrypted_file_name": "",
            "result": []
            }
   ]
}
</code></pre></td></tr></tbody></table>
