Packeta PUDOs
When creating packets to our Packeta PUDOs through our API you have to select the destination PUDO using
it's ID obtained from our Widget or from our Packeta PUDOs feed.
- REST
- SOAP
- PHP
- C#
- Node.js
<!--request-->
<createPacket>
<apiPassword>{{API_PASSWORD}}</apiPassword>
<packetAttributes>
<number>orderNumber</number>
<name>John</name>
<surname>Doe</surname>
<company>Company</company>
<email>example@packetatest.com</email>
<phone>+420777777777</phone>
<addressId>52</addressId>
<cod>115</cod>
<value>115</value>
<currency>CZK</currency>
<weight>2.5</weight>
<eshop>{{SENDER_INDICATION}}</eshop>
</packetAttributes>
</createPacket>
<!--response-->
<response>
<status>ok</status>
<result>
<id>4154090000</id>
<barcode>Z4154090000</barcode>
<barcodeText>Z 415 4090 000</barcodeText>
</result>
</response>
<!--request-->
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://www.zasilkovna.cz/api/soap.wsdl2" xmlns:soap1="http://www.zasilkovna.cz/api/soap.wsdl">
<soapenv:Header/>
<soapenv:Body>
<soap:createPacket>
<apiPassword>{{API_PASSWORD}}</apiPassword>
<attributes>
<soap1:number>orderNumber</soap1:number>
<soap1:name>John</soap1:name>
<soap1:surname>Doe</soap1:surname>
<soap1:company>Company</soap1:company>
<soap1:email>example@packetatest.com</soap1:email>
<soap1:phone>+420777777777</soap1:phone>
<soap1:addressId>52</soap1:addressId>
<soap1:cod>115</soap1:cod>
<soap1:value>115</soap1:value>
<soap1:currency>CZK</soap1:currency>
<soap1:weight>2.5</soap1:weight>
<soap1:eshop>MyEshop</soap1:eshop>
</attributes>
</soap:createPacket>
</soapenv:Body>
</soapenv:Envelope>
<!--response-->
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.zasilkovna.cz/api/soap.wsdl">
<SOAP-ENV:Body>
<ns1:createPacketResponse>
<createPacketResult>
<ns1:id>1435371000</ns1:id>
<ns1:barcode>Z1435371000</ns1:barcode>
<ns1:barcodeText>Z 143 5371 000</ns1:barcodeText>
</createPacketResult>
</ns1:createPacketResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<?php
$apiPassword = 'apiPassword';
$packetAttributes = [
'number' => '20220513001',
'name' => 'John',
'surname' => 'Doe',
'company' => 'Company',
'email' => 'example@packetatest.com',
'phone' => '+420777123456',
'addressId' => 52,
'cod' => 115,
'value' => '115',
'currency' => 'CZK',
'weight' => 2.5,
'eshop' => 'MyEshop',
];
try {
$client = new SoapClient('https://www.zasilkovna.cz/api/soap.wsdl');
$result = $client->createPacket($apiPassword, $packetAttributes);
var_dump($result);
} catch (SoapFault $e) {
echo $e->getMessage();
if (isset($e->detail->PacketAttributesFault)) {
var_dump($e->detail->PacketAttributesFault->attributes->fault);
} elseif (isset($e->detail->IncorrectApiPasswordFault)) {
var_dump('Incorrect API password.');
}
}
?>
using System;
using System.ServiceModel;
using System.Threading.Tasks;
using PacketaService;
namespace PacketaClientExample
{
class Program
{
static async Task Main(string[] args)
{
BasicHttpsBinding binding = new BasicHttpsBinding();
EndpointAddress endpointAddress = new EndpointAddress("https://www.zasilkovna.cz/api/soap");
const string apiPassword = "apiPassword";
PacketAttributes packetAttributes = new PacketAttributes
{
number = "orderNumber"
name = "John",
surname = "Doe",
company = "Company",
email = "example@packetatest.com",
phone = "+420777777777",
addressId = 1817,
cod = 115,
value = 115,
currency = "CZK",
weight = 2.5,
eshop = "MyEshop",
};
PacketaClient client = new PacketaClient(binding, endpointAddress);
try
{
createPacketResponse response = await client.createPacketAsync(new createPacketRequest(apiPassword, packetAttributes));
//Process response
Console.WriteLine(response.createPacketResult.id);
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
import { Builder, Parser } from "xml2js"
const requestBody = {
createPacket: {
apiPassword: "apiPassword",
packetAttributes: {
number: "orderNumber",
name: "John",
surname: "Doe",
company: "Company",
email: "example@packetatest.com",
phone: "+420777777777",
addressId: 1817,
cod: 115,
value: 115,
currency: EUR,
weight: 2.5,
eshop: "MyEshop",
}
}
}
try {
const response = await fetch(
"https://www.zasilkovna.cz/api/rest",
{
method: "POST",
body: new Builder().buildObject(requestBody)
}
);
const responseBody = await new Parser({ explicitArray: false }).parseStringPromise(await response.text());
//process response
console.log(responseBody.response.result.id);
}
catch (exception) {
console.log(exception);
}