# Reprint By Reference

## Reprint By Reference

This function has the same aim of [reprint](https://apidocs.gsped.com/gsped-api-english-version/spedizioni-e-dintorni/reprint "mention") endpoint, but uses the numeric or alphanumeric reference istead of researching with the Gsped ID of the shipment.

{% hint style="success" %}
For this endpoint you must use unique references.
{% endhint %}

## Reprint labels via file

<mark style="color:blue;">`GET`</mark> `https://api.gsped.it/[INSTANCE]/reprintByReference`

Use the numerical OR alphanumerical reference

#### Query Parameters

| Name                                         | Type   | Description              |
| -------------------------------------------- | ------ | ------------------------ |
| ddt\_num<mark style="color:red;">\*</mark>   | String | Numerical reference      |
| ddt\_alpha<mark style="color:red;">\*</mark> | String | Alphanumerical reference |

#### Headers

| Name                                        | Type   | Description           |
| ------------------------------------------- | ------ | --------------------- |
| x-api-key<mark style="color:red;">\*</mark> | String | Apikey given by Gsped |

{% tabs %}
{% tab title="200: OK Label printed" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="400: Bad Request Not unique DDT" %}

```javascript
{
    "error": "ddt_num non univoco"
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid parameters" %}

```javascript
{
  "error": "ddt_alpha o ddt_num spedizione non indicata"
}
```

{% endtab %}

{% tab title="403: Forbidden Invalid Apikey" %}

```javascript
{
  "status": false,
  "error": "Invalid API key "
}
```

{% endtab %}

{% tab title="404: Not Found Not found" %}

```javascript
{
  "error": "Spedizione non trovata"
}
```

{% endtab %}
{% endtabs %}

**Example Snippets**

{% tabs %}
{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.gsped.it/sandbox/ReprintByReference?ddt_alpha=test1234",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => [
    "x-api-key: YOUR-API-KEY"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

{% endtab %}

{% tab title="PYTHON" %}

```python
import http.client

conn = http.client.HTTPSConnection("api.gsped.it")

payload = ""

headers = { 'x-api-key': "YOUR-API-KEY" }

conn.request("GET", "/sandbox/ReprintByReference?ddt_alpha=test1234", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
```

{% endtab %}

{% tab title="GO" %}

```go
package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://api.gsped.it/sandbox/ReprintByReference?ddt_alpha=test1234"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("x-api-key", "YOUR-API-KEY")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage
{
    Method = HttpMethod.Get,
    RequestUri = new Uri("https://api.gsped.it/sandbox/ReprintByReference?ddt_alpha=test1234"),
    Headers =
    {
        { "x-api-key", "YOUR-API-KEY" },
    },
};
using (var response = await client.SendAsync(request))
{
    response.EnsureSuccessStatusCode();
    var body = await response.Content.ReadAsStringAsync();
    Console.WriteLine(body);
}
```

{% endtab %}

{% tab title="cURL" %}

```shell
curl --request GET \
  --url 'https://api.gsped.it/sandbox/ReprintByReference?ddt_alpha=test1234' \
  --header 'x-api-key: YOUR-API-KEY'
```

{% endtab %}
{% endtabs %}
