I denne artikel bruger vi SubmitShipment-metoden på API'en til at oprette/booke en forsendelse
https://nshiftship.zendesk.com/hc/da/articles/23142488632988#post_shipments
Men afhængigt af den flow, du implementerer, kan en af følgende metoder være et bedre valg:
- https://nshiftship.zendesk.com/hc/da/articles/23142488632988#post_saveshipment
- https://nshiftship.zendesk.com/hc/da/articles/23142488632988#post_importUpload
- https://nshiftship.zendesk.com/hc/da/articles/23142488632988#post_orderAdvice
- https://nshiftship.zendesk.com/hc/da/articles/23142488632988#post_submitOrder
Før du fortsætter, bedes du se på følgende sektion i API-dokumentationen:
https://nshiftship.zendesk.com/hc/da/articles/23142488632988#post_shipments_options
https://nshiftship.zendesk.com/hc/da/articles/23093866504604-Shipment-Data-Object
Miljø URL
Eksempler på, hvordan man booker en forsendelse
Dataobjektet definerer forsendelsen, og Options-objektet giver konfiguration til metoden.
Eksempel 1. (enkelt pakke)
Eksempel 2. (flere pakker med samme vægt)
Eksempel 3. (flere pakker med forskellige vægte)
Eksempel 1. (enkelt pakke)
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\" }
}"Eksempel 2. (flere pakker med samme vægt)
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\" }
}"Eksempel 3. (flere pakker med forskellige vægte)
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\" }
}"
Svar
Alle eksempler vil generere et svar som nedenstående
{
"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 - Labels returneres i det ønskede format, men kodet med base64
- ShpDocuments - Information om genererede Labels og Dokumenter
-
ShpDocuments[1].ShpCSID - brug get_documents-metoden til at hente dokumenterne
https://nshiftship.zendesk.com/hc/da/articles/23142488632988-API-Documentation#get_documents