> For the complete documentation index, see [llms.txt](https://docs.api.persat.com.ar/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.api.persat.com.ar/modulos/ordenes-de-trabajo/obtener-pdf-de-la-ot.md).

# Obtener PDF de la OT

Para obtener el PDF de una OT particular que ya ha sido completada en Persat se debe realizar un GET como el que se muestra a continuación.

<mark style="color:blue;">`GET`</mark> `https://api.persat.com.ar/v1/work-orders/pdf/wo_id`

{% hint style="danger" %}
Solo se pueden obtener una vez que se hayan realizado. Es decir, una vez que esté en estado   INFORME, VENCIDA, CERRADA\_OK, CERRADA\_CON\_DESVIO o CERRADA\_NO\_CUMPLIDA.
{% endhint %}

#### Path Parameters

| Name                                     | Type   | Description             |
| ---------------------------------------- | ------ | ----------------------- |
| wo\_id<mark style="color:red;">\*</mark> | String | Identificador de la ot. |

#### Query Parameters

| Name   | Type   | Description                                                                                                      |
| ------ | ------ | ---------------------------------------------------------------------------------------------------------------- |
| format | String | Si se envía `"base64"`, el PDF se devolverá en base64. Si no se envía, la API responderá con un archivo binario. |

#### Headers

| Name                                            | Type   | Description     |
| ----------------------------------------------- | ------ | --------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer API\_KEY |

### Ejemplo en formato binario

{% hint style="info" %}
Las respuestas en formato binario retornan directamente la descarga del archivo.
{% endhint %}

#### Request con curl

```bash
curl -H "Authorization: Bearer API_KEY" \
     -J -O \
     https://api.persat.com.ar/v1/work-orders/pdf/197
```

#### Respuesta

{% tabs %}
{% tab title="200: OK La consulta se ejecutó con éxito" %}
{% code overflow="wrap" fullWidth="true" %}

```json
HTTP/1.1 200 OK
Content-Type: application/pdf
Transfer-Encoding: chunked
Content-Disposition: attachment; filename="Aire_acondicionado_20.pdf"

<Binary Data>
```

{% endcode %}
{% endtab %}

{% tab title="409: CONFLICT" %}

```json
HTTP/1.1 409 CONFLICT
Content-Type: application/json

{
    "success": false,
    "error": {
        "status": 409,
        "type": "CONFLICT",
        "userMessage": "La orden de trabajo '21' debe tener los resultados definidos para poder generar el PDF"
    }
}
```

{% endtab %}

{% tab title="404: NOT FOUND No se encontró la OT " %}

```json
HTTP/1.1 404 NOT_FOUND
Content-Type: application/json

{
    "success": false,
    "error": {
        "status": 404,
        "type": "NOT_FOUND",
        "userMessage": "No hay una ot con este numero de wo_id: 197"
    }
}
```

{% endtab %}
{% endtabs %}

### Analizando la Respuesta en formato base64

{% tabs %}
{% tab title="200: OK La consulta se ejecutó con éxito" %}

```json
{
    "success": true,
    "data": {
        "pdf": "JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9DcmVh[...]", // Base64
        "name": "Aire_acondicionado_20.pdf",
    }
}
```

{% endtab %}

{% tab title="409: CONFLICT" %}

```json
{
    "success": false,
    "error": {
        "status": 409,
        "type": "CONFLICT",
        "userMessage": "La orden de trabajo '21' debe tener los resultados definidos para poder generar el PDF"
    }
}
```

{% endtab %}

{% tab title="404: Not Found No se encontro el formulario requerido" %}

```json
{
    "success": false,
    "error": {
        "status": 404,
        "type": "NOT_FOUND",
        "userMessage": "No hay una ot con este numero de wo_id: 197"
    }
}
```

{% endtab %}
{% endtabs %}

**pdf:** Es un string. Representa el pdf en base64.

**name:** Es un string. Nombre sugerido del pdf.

### Ejemplo de PDF descargado

<figure><img src="/files/RVYSWFOFIlukhtmXHwaF" alt=""><figcaption><p>Ejemplo de pdf descargado</p></figcaption></figure>
