Tässä artikkelissa käytämme API:n SubmitShipment-metodia lähetyksen luomiseen/varaamiseen
https://nshiftship.zendesk.com/hc/fi/articles/23142488632988#post_shipments
Mutta riippuen toteuttamastasi prosessista, jokin seuraavista menetelmistä voi olla parempi vaihtoehto:
- https://nshiftship.zendesk.com/hc/fi/articles/23142488632988#post_saveshipment
- https://nshiftship.zendesk.com/hc/fi/articles/23142488632988#post_importUpload
- https://nshiftship.zendesk.com/hc/fi/articles/23142488632988#post_orderAdvice
- https://nshiftship.zendesk.com/hc/fi/articles/23142488632988#post_submitOrder
Ennen kuin jatkat, tutustu seuraavaan API-dokumentaation osioon:
https://nshiftship.zendesk.com/hc/fi/articles/23142488632988#post_shipments_options
https://nshiftship.zendesk.com/hc/fi/articles/23093866504604-Shipment-Data-Object
Ympäristön URL-osoitteet
Esimerkkejä lähetyksen varaamisesta
Data Object määrittelee lähetyksen, ja Options Object tarjoaa metodin konfiguroinnin.
Esimerkki 1. (yksi paketti)
Esimerkki 2. (useita paketteja, sama paino)
Esimerkki 3. (useita paketteja, eri painot)
Esimerkki 1. (yksi paketti)
curl -s -X POST "{{URL}}/ShipServer/{{ACTOR_ID}}/Shipments"
-H "Authorization: {{TOKEN}}"
-H "Content-Type: application/json"
--data-raw "{
\"data\": {
\"ProdConceptID\": 1782,
\"OrderNo\": \"Test Shipment 1\",
\"Addresses\": [{
\"Kind\": 1,
\"Name1\": \"Test Receiver Name1\",
\"Street1\": \"Test Road 1\",
\"PostCode\": 7400,
\"City\": \"Herning\",
\"CountryCode\": \"DK\",
\"Phone\": \"12341234\",
\"Mobile\": \"12341234\",
\"Email\": \"noreply@nshift.com\",
\"Attention\": \"Test Attention\"
},{
\"Kind\": 2,
\"Name1\": \"Test Sender Name1\",
\"Street1\": \"Test Road 1\",
\"PostCode\": 6400,
\"City\": \"Sønderborg\",
\"CountryCode\": \"DK\",
\"Phone\": \"12341234\",
\"Mobile\": \"12341234\",
\"Email\": \"noreply@nshift.com\",
\"Attention\": \"Test Attention\"
}],
\"Lines\":[{
\"Number\": 1,
\"PkgWeight\": 10000,
\"Height\": 100,
\"Length\": 100,
\"Width\": 100,
\"GoodsTypeID\": 13,
\"References\": [{
\"Kind\": 23,
\"Value\": \"Test Shipment - Do not process !\"
}]
}]
},
\"options\": { \"Labels\": \"ZPLGK\" }
}"Esimerkki 2. (useita paketteja, sama paino)
curl -s -X POST "{{URL}}/ShipServer/{{ACTOR_ID}}/Shipments"
-H "Authorization: {{TOKEN}}"
-H "Content-Type: application/json"
--data-raw "{
\"data\": {
\"ProdConceptID\": 1782,
\"OrderNo\": \"Test Shipment 1\",
\"Addresses\": [{
\"Kind\": 1,
\"Name1\": \"Test Receiver Name1\",
\"Street1\": \"Test Road 1\",
\"PostCode\": 7400,
\"City\": \"Herning\",
\"CountryCode\": \"DK\",
\"Phone\": \"12341234\",
\"Mobile\": \"12341234\",
\"Email\": \"noreply@nshift.com\",
\"Attention\": \"Test Attention\"
},{
\"Kind\": 2,
\"Name1\": \"Test Sender Name1\",
\"Street1\": \"Test Road 1\",
\"PostCode\": 6400,
\"City\": \"Sønderborg\",
\"CountryCode\": \"DK\",
\"Phone\": \"12341234\",
\"Mobile\": \"12341234\",
\"Email\": \"noreply@nshift.com\",
\"Attention\": \"Test Attention\"
}],
\"Lines\":[{
\"Number\": 2,
\"PkgWeight\": 10000,
\"Height\": 100,
\"Length\": 100,
\"Width\": 100,
\"GoodsTypeID\": 13,
\"References\": [{
\"Kind\": 23,
\"Value\": \"Test Shipment - Do not process !\"
}]
}]
},
\"options\": { \"Labels\": \"ZPLGK\" }
}"Esimerkki 3. (useita paketteja, eri painot)
curl -s -X POST "{{URL}}/ShipServer/{{ACTOR_ID}}/Shipments"
-H "Authorization: {{TOKEN}}"
-H "Content-Type: application/json"
--data-raw "{
\"data\": {
\"ProdConceptID\": 1782,
\"OrderNo\": \"Test Shipment 1\",
\"Addresses\": [{
\"Kind\": 1,
\"Name1\": \"Test Receiver Name1\",
\"Street1\": \"Test Road 1\",
\"PostCode\": 7400,
\"City\": \"Herning\",
\"CountryCode\": \"DK\",
\"Phone\": \"12341234\",
\"Mobile\": \"12341234\",
\"Email\": \"noreply@nshift.com\",
\"Attention\": \"Test Attention\"
},{
\"Kind\": 2,
\"Name1\": \"Test Sender Name1\",
\"Street1\": \"Test Road 1\",
\"PostCode\": 6400,
\"City\": \"Sønderborg\",
\"CountryCode\": \"DK\",
\"Phone\": \"12341234\",
\"Mobile\": \"12341234\",
\"Email\": \"noreply@nshift.com\",
\"Attention\": \"Test Attention\"
}],
\"Lines\":[{
\"Number\": 1,
\"PkgWeight\": 10000,
\"Height\": 100,
\"Length\": 100,
\"Width\": 100,
\"GoodsTypeID\": 13,
\"References\": [{
\"Kind\": 23,
\"Value\": \"Test Shipment - Do not process !\"
}]
},{
\"Number\": 1,
\"PkgWeight\": 15000,
\"Height\": 100,
\"Length\": 100,
\"Width\": 100,
\"GoodsTypeID\": 13,
\"References\": [{
\"Kind\": 23,
\"Value\": \"Test Shipment - Do not process !\"
}]
}]
},
\"options\": { \"Labels\": \"ZPLGK\" }
}"
Vastaus
Kaikki esimerkit tuottavat alla olevan kaltaisen vastauksen
{
"ShpCSID": 161323,
"ShpNo": "70730254433124072",
"OrderNo": "Test Shipment 1",
"ProdConceptID": 1782,
"Addresses": [...],
"Lines": [...],
"Labels": [{
"Content": "XlhBXkNXSSxFOlotRVB...",
"Type": 13,
"Copies": 1,
"PkgCSID": 162500,
"PkgNo": "00370730254433124088"
}, {
"Content": "XlhBXkNXSSxFOlotRVB...",
"Type": 13,
"Copies": 1,
"PkgCSID": 162501,
"PkgNo": "00370730254433124095"
}
],
"ShpDocuments": [{
"ShpCSID": 161323,
"DocumentID": 1217,
"DocumentCSID": 165178,
"Copies": 1,
"DocumentName": "Generic Sweden",
"PrintedDt": "2022-08-04T12:56:40",
"DocumentType": "Label"
}, {
"ShpCSID": 161323,
"DocumentID": 104,
"DocumentCSID": 165179,
"Copies": 1,
"DocumentName": "SE.Fraktsedel",
"PrintedDt": "2022-08-04T12:56:40",
"DocumentType": "FreightLetter"
}
]
}- Labels[0].Content - Tarrat palautetaan pyydetyssä formaatissa, mutta base64-koodattuina
- ShpDocuments - Tietoa luoduista tarroista ja asiakirjoista
-
ShpDocuments[1].ShpCSID - käytä get_documents-metodia saadaksesi asiakirjat
https://nshiftship.zendesk.com/hc/fi/articles/23142488632988-API-Documentation#get_documents