Add Parcel
Gestione dei colli in modo dinamico
La funzionalità Add Parcel da la possibilità, una volta creata la spedizione principale, di aggiungere o rimuovere colli in modo indipendente ottendendo le relative etichette.
CORRIERE (ID Gsped) | AGGIUNTA COLLI | RIMOZIONE COLLI |
---|---|---|
BRT (1)
N.B. solo soluz. B2 | Sì | Sì |
TNT (2) | Sì | Sì |
Italsempione (90) | Sì | Sì |
ARCO (100) | Sì | Sì |
GLS (101) | Sì | No |
Fercam (131) | Sì | Sì |
LICCARDI (179) | SI | SI |
DHL WLA (182) | Sì | Sì |
La lista dei corrieri abilitati è soggetta a modifiche, si prega i verificare gli aggiornamenti ad intervalli regolari
Per utilizzare nel modo corretto la funzionalità Add Parcel bisogna utilizzare 3 endpoint:
- 1.Shipment POST - Per la creazione della spedizione
- 2.Parcels POST o DELETE - Per l'aggiunta o la rimozione dei colli
- 3.ShipmentConfirm POST - Per la conferma finale della spedizione e relativa chiusura alle modifiche
ATTENZIONE: La rimozione dell'unico collo di una spedizione equivale alla cancellazione della stessa.
ATTENZIONE: La conferma di una spedizione inibisce la possibilità di aggiungere o rimuover colli da una spedizione
post
https://api.gsped.it
/[istanza]/Parcels
Aggiunta singolo collo a spedizione
Attributo | Tipo | Required |
---|---|---|
peso | integer | X |
volume | float | X |
larghezza | integer | X |
altezza | integer | X |
lunghezza | integer | X |
ID Spedizione
Dati Destinatario
{
"id_sped":"1234567",
"collo": {
"peso": "5",
"volume": "0.01",
"larghezza": "35",
"altezza": "15",
"lunghezza": "10"
}
}
{
"ddt_alpha":"test_parcel_8",
"rcpt_name":"Rossi Gino",
"rcpt_addr":"Via Milano 8",
"rcpt_cap":"20123",
"rcpt_city":"Milano",
"rcpt_prov":"MI",
"rcpt_country_code" : "IT",
"collo": {
"peso": "5",
"volume": "0.01",
"larghezza": "35",
"altezza": "15",
"lunghezza": "20"
}
}
PHP
Python
GO
C#
cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gsped.it/sandbox/Parcels",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"id_sped\":\"1\",\n \"collo\": {\n \"peso\": \"5\",\n \"volume\": \"0.01\",\n \"larghezza\": \"35\",\n \"altezza\": \"15\",\n \"lunghezza\": \"10\"\n }\n}",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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;
}
import http.client
conn = http.client.HTTPSConnection("api.gsped.it")
payload = "{\n \"id_sped\":\"1\",\n \"collo\": {\n \"peso\": \"5\",\n \"volume\": \"0.01\",\n \"larghezza\": \"35\",\n \"altezza\": \"15\",\n \"lunghezza\": \"10\"\n }\n}"
headers = {
'Content-Type': "application/json",
'x-api-key': "YOUR-API-KEY"
}
conn.request("POST", "/sandbox/Parcels", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.gsped.it/sandbox/Parcels"
payload := strings.NewReader("{\n \"id_sped\":\"1\",\n \"collo\": {\n \"peso\": \"5\",\n \"volume\": \"0.01\",\n \"larghezza\": \"35\",\n \"altezza\": \"15\",\n \"lunghezza\": \"10\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
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))
}
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("https://api.gsped.it/sandbox/Parcels"),
Headers =
{
{ "x-api-key", "YOUR-API-KEY" },
},
Content = new StringContent("{\n \"id_sped\":\"1\",\n \"collo\": {\n \"peso\": \"5\",\n \"volume\": \"0.01\",\n \"larghezza\": \"35\",\n \"altezza\": \"15\",\n \"lunghezza\": \"10\"\n }\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
curl --request POST \
--url https://api.gsped.it/sandbox/Parcels \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR-API-KEY' \
--data '{
"id_sped":"1",
"collo": {
"peso": "5",
"volume": "0.01",
"larghezza": "35",
"altezza": "15",
"lunghezza": "10"
}
}'
delete
https://api.gsped.it
/[istanza]/Parcels
Rimozione collo da spedizione
PHP
Python
GO
C#
cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gsped.it/sandbox/Parcels",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => "id_sped=69562763",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded",
"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;
}
import http.client
conn = http.client.HTTPSConnection("api.gsped.it")
payload = "id_sped=69562763"
headers = {
'Content-Type': "application/x-www-form-urlencoded",
'x-api-key': "YOUR-API-KEY"
}
conn.request("DELETE", "/sandbox/Parcels", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.gsped.it/sandbox/Parcels"
payload := strings.NewReader("id_sped=69562763")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
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))
}
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Delete,
RequestUri = new Uri("https://api.gsped.it/sandbox/Parcels"),
Headers =
{
{ "x-api-key", "YOUR-API-KEY" },
},
Content = new FormUrlEncodedContent(new Dictionary<string, string>
{
{ "id_sped", "69562763" },
}),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}c
curl --request DELETE \
--url https://api.gsped.it/sandbox/Parcels \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'x-api-key: YOUR-API-KEY' \
--data id_sped=69562763
Last modified 2mo ago