Introduzione
Questo endpoint nasce come punto di ingresso per flussi informativi che risiedono su altri sistemi o integrazioni.
Si tratta di un endpoint chiamato in POST con payload in JSON.
Specifiche chiamata
Esempio payload
Copy {
"client_id" : 2 ,
"instance" : "testbed" ,
"courier" : 104 ,
"shipment_number" : "123456789" ,
"reference_1" : 11223 ,
"reference_2" : "11223" ,
"parcels" : 1 ,
"status" : "PU" ,
"weight" : 2.5 ,
"volume" : 0.005 ,
"service" : "N" ,
"insurance" : 0.0 ,
"cod" : 0.0 ,
"parcel_details" : [
{
"barcode" : "12345" ,
"weight" : 2.5 ,
"volume" : 0.005 ,
"height" : 10 ,
"length" : 10 ,
"width" : 10 ,
"type" : "crt"
}
] ,
"sender_info" : {
"name" : "test" ,
"address" : "via delle Glorie 5" ,
"city" : "Alessandria" ,
"zipcode" : "15121" ,
"state" : "AL" ,
"country" : "IT" ,
"phone" : "1231212123" ,
"mail" : "test@test.it"
} ,
"recipient_info" : {
"name" : "test" ,
"address" : "via delle rose 14" ,
"city" : "Milano" ,
"zipcode" : "20121" ,
"state" : "MI" ,
"country" : "IT" ,
"phone" : "1231212123" ,
"mail" : "test@test.it"
} ,
"order_id" : 4743
}
Definizione campi
Apikey rilasciata da Gsped
Request Body
Numero colli della spedizione
Volume spedizione in Metri Cubi
Peso spedizione espresso in KG
Codice stato spedizione in formato corriere
Riferimento numerico della spedizione
Riferimento alfanumerico della spedizione
ID cliente fornito da Gsped
Codice servizio in formato corriere
ID Gsped dell'ordine associato alla spedizione
Address Object
Iso code 2 char della nazione
Parcel_data Object
Esempi di codice
PHP
Copy <? php
$curl = curl_init () ;
curl_setopt_array ( $curl , [
CURLOPT_URL => "https://apiproduction.gsped.it/testbed/ShipmentFromCourier" ,
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\t\"client_id\" : 2,\n\t\"instance\" : \"testbed\",\n\t\"courier\" : 104,\n\t\"shipment_number\" : \"123456789\",\n\t\"reference_1\" : 11223,\n\t\"reference_2\": \"11223\",\n\t\"parcels\" : 1,\n\t\"status\" : \"PU\",\n\t\"weight\": 2.5,\n\t\"volume\": 0.005,\n\t\"service\": \"N\",\n\t\"insurance\": 0.0,\n\t\"cod\": 0.0,\n\t\"parcel_details\": [\n\t\t{\n\t\t\t\"barcode\": \"12345\",\n\t\t\t\"weight\": 2.5,\n\t\t\t\"volume\": 0.005,\n\t\t\t\"height\": 10,\n\t\t\t\"length\": 10,\n\t\t\t\"width\": 10,\n\t\t\t\"type\": \"crt\"\n\t\t}\n\t],\n\t\"sender_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle Glorie 5\",\n\t\t\"city\": \"Alessandria\",\n\t\t\"zipcode\": \"15121\",\n\t\t\"state\": \"AL\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"recipient_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle rose 14\",\n\t\t\"city\": \"Milano\",\n\t\t\"zipcode\": \"20121\",\n\t\t\"state\": \"MI\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"order_id\": 4743\n}",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json" ,
"x-api-key: 9515986E77D2F2CEE97C572D6943E"
] ,
] ) ;
$response = curl_exec ( $curl ) ;
$err = curl_error ( $curl ) ;
curl_close ( $curl ) ;
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Python
Copy import http . client
conn = http . client . HTTPSConnection ( "apiproduction.gsped.it" )
payload = "{\n\t\"client_id\" : 2,\n\t\"instance\" : \"testbed\",\n\t\"courier\" : 104,\n\t\"shipment_number\" : \"123456789\",\n\t\"reference_1\" : 11223,\n\t\"reference_2\": \"11223\",\n\t\"parcels\" : 1,\n\t\"status\" : \"PU\",\n\t\"weight\": 2.5,\n\t\"volume\": 0.005,\n\t\"service\": \"N\",\n\t\"insurance\": 0.0,\n\t\"cod\": 0.0,\n\t\"parcel_details\": [\n\t\t{\n\t\t\t\"barcode\": \"12345\",\n\t\t\t\"weight\": 2.5,\n\t\t\t\"volume\": 0.005,\n\t\t\t\"height\": 10,\n\t\t\t\"length\": 10,\n\t\t\t\"width\": 10,\n\t\t\t\"type\": \"crt\"\n\t\t}\n\t],\n\t\"sender_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle Glorie 5\",\n\t\t\"city\": \"Alessandria\",\n\t\t\"zipcode\": \"15121\",\n\t\t\"state\": \"AL\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"recipient_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle rose 14\",\n\t\t\"city\": \"Milano\",\n\t\t\"zipcode\": \"20121\",\n\t\t\"state\": \"MI\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"order_id\": 4743\n}"
headers = {
'Content-Type' : "application/json" ,
'x-api-key' : "9515986E77D2F2CEE97C572D6943E"
}
conn . request ( "POST" , "/testbed/ShipmentFromCourier" , payload, headers)
res = conn . getresponse ()
data = res . read ()
print (data. decode ( "utf-8" ))
GO
Copy package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main () {
url := "https://apiproduction.gsped.it/testbed/ShipmentFromCourier"
payload := strings.NewReader("{\n\t\"client_id\" : 2,\n\t\"instance\" : \"testbed\",\n\t\"courier\" : 104,\n\t\"shipment_number\" : \"123456789\",\n\t\"reference_1\" : 11223,\n\t\"reference_2\": \"11223\",\n\t\"parcels\" : 1,\n\t\"status\" : \"PU\",\n\t\"weight\": 2.5,\n\t\"volume\": 0.005,\n\t\"service\": \"N\",\n\t\"insurance\": 0.0,\n\t\"cod\": 0.0,\n\t\"parcel_details\": [\n\t\t{\n\t\t\t\"barcode\": \"12345\",\n\t\t\t\"weight\": 2.5,\n\t\t\t\"volume\": 0.005,\n\t\t\t\"height\": 10,\n\t\t\t\"length\": 10,\n\t\t\t\"width\": 10,\n\t\t\t\"type\": \"crt\"\n\t\t}\n\t],\n\t\"sender_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle Glorie 5\",\n\t\t\"city\": \"Alessandria\",\n\t\t\"zipcode\": \"15121\",\n\t\t\"state\": \"AL\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"recipient_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle rose 14\",\n\t\t\"city\": \"Milano\",\n\t\t\"zipcode\": \"20121\",\n\t\t\"state\": \"MI\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"order_id\": 4743\n}")
req, _ := http. NewRequest ( "POST" , url, payload)
req.Header. Add ( "Content-Type" , "application/json" )
req.Header. Add ( "x-api-key" , "9515986E77D2F2CEE97C572D6943E" )
res, _ := http.DefaultClient. Do (req)
defer res.Body. Close ()
body, _ := ioutil. ReadAll (res.Body)
fmt. Println (res)
fmt. Println ( string (body))
}
C#
Copy var client = new RestClient ( "https://apiproduction.gsped.it/testbed/ShipmentFromCourier" );
var request = new RestRequest ( Method . POST );
request .AddHeader( "Content-Type" , "application/json" );
request .AddHeader( "x-api-key" , "9515986E77D2F2CEE97C572D6943E" );
request.AddParameter("application/json", "{\n\t\"client_id\" : 2,\n\t\"instance\" : \"testbed\",\n\t\"courier\" : 104,\n\t\"shipment_number\" : \"123456789\",\n\t\"reference_1\" : 11223,\n\t\"reference_2\": \"11223\",\n\t\"parcels\" : 1,\n\t\"status\" : \"PU\",\n\t\"weight\": 2.5,\n\t\"volume\": 0.005,\n\t\"service\": \"N\",\n\t\"insurance\": 0.0,\n\t\"cod\": 0.0,\n\t\"parcel_details\": [\n\t\t{\n\t\t\t\"barcode\": \"12345\",\n\t\t\t\"weight\": 2.5,\n\t\t\t\"volume\": 0.005,\n\t\t\t\"height\": 10,\n\t\t\t\"length\": 10,\n\t\t\t\"width\": 10,\n\t\t\t\"type\": \"crt\"\n\t\t}\n\t],\n\t\"sender_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle Glorie 5\",\n\t\t\"city\": \"Alessandria\",\n\t\t\"zipcode\": \"15121\",\n\t\t\"state\": \"AL\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"recipient_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle rose 14\",\n\t\t\"city\": \"Milano\",\n\t\t\"zipcode\": \"20121\",\n\t\t\"state\": \"MI\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"order_id\": 4743\n}", ParameterType.RequestBody);
IRestResponse response = client .Execute(request);
Curl
Copy curl --request POST \
--url https://apiproduction.gsped.it/testbed/ShipmentFromCourier \
--header 'Content-Type: application/json' \
--header 'x-api-key: 9515986E77D2F2CEE97C572D6943E' \
--data '{
"client_id" : 2,
"instance" : "testbed",
"courier" : 104,
"shipment_number" : "123456789",
"reference_1" : 11223,
"reference_2": "11223",
"parcels" : 1,
"status" : "PU",
"weight": 2.5,
"volume": 0.005,
"service": "N",
"insurance": 0.0,
"cod": 0.0,
"parcel_details": [
{
"barcode": "12345",
"weight": 2.5,
"volume": 0.005,
"height": 10,
"length": 10,
"width": 10,
"type": "crt"
}
],
"sender_info": {
"name": "test",
"address": "via delle Glorie 5",
"city": "Alessandria",
"zipcode": "15121",
"state": "AL",
"country": "IT",
"phone": "1231212123",
"mail": "test@test.it"
},
"recipient_info": {
"name": "test",
"address": "via delle rose 14",
"city": "Milano",
"zipcode": "20121",
"state": "MI",
"country": "IT",
"phone": "1231212123",
"mail": "test@test.it"
},
"order_id": 4743
}'
Limitazioni
Al momento questo endpoint è disponibile solo per i corrieri:
In futuro verrà espanso, visitate la documentazione ad intervalli regolari per essere aggiornati.