Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BulkCreate just for multicollo? #30

Open
jpp-skynet opened this issue Jul 12, 2024 · 3 comments
Open

BulkCreate just for multicollo? #30

jpp-skynet opened this issue Jul 12, 2024 · 3 comments

Comments

@jpp-skynet
Copy link

Tried to create 3 parcels of unrelated orders at once with BulkCreate, but just one was returned and created.

@janssenr
Copy link
Owner

janssenr commented Jul 12, 2024 via email

@jpp-skynet
Copy link
Author

I switched to singleParcel and they have errors (missing zipcode, weight too much,..),

The problem is that BulkCreate seems to hide them, or at least I cannot see them I am just getting a general Sendcloud Exception IIRC.

If BulkCreate should work for parcels from different orders I'll trust you.

Btw, do you have this implemented?

https://api.sendcloud.dev/docs/sendcloud-public-api/labels/operations/get-a-label-label-printer-1
Retrieve PDF label documents suitable for label printers for multiple different parcels at the same time.

I

@janssenr
Copy link
Owner

janssenr commented Jul 13, 2024

This code works. The response contains 2 parcels

var parcels = new[]
            {
                new CreateParcel
                {
                    Name = "John Doe",
                    CompanyName = "SendCloud",
                    Address = "Insulindelaan",
                    HouseNumber = "115",
                    City = "Eindhoven",
                    PostalCode = "5642CV",
                    Telephone = "+31612345678",
                    RequestLabel = true,
                    Email = "john@doe.com",
                    Country = "NL",
                    Shipment = new ShippingMethod { Id = 8 },
                    Weight = 10,
                    OrderNumber = "1234567890",
                    InsuredValue = 2000,
                    TotalOrderValue = "11.11",
                    TotalOrderValueCurrency = "EUR",
                    Quantity = 1
                },
                new CreateParcel
                {
                    Name = "John Doe",
                    CompanyName = "SendCloud",
                    Address = "Insulindelaan",
                    HouseNumber = "115",
                    City = "Eindhoven",
                    PostalCode = "5642CV",
                    Telephone = "+31612345678",
                    RequestLabel = true,
                    Email = "john@doe.nl",
                    Country = "NL",
                    Shipment = new ShippingMethod { Id = 8 },
                    Weight = 8,
                    OrderNumber = "1234567891",
                    InsuredValue = 500,
                    TotalOrderValue = "99.99",
                    TotalOrderValueCurrency = "EUR",
                    Quantity = 1
                }
            };
            var response = await _apiV2.Parcels.BulkCreate(parcels);

For the "Retrieve PDF label documents suitable for label printers for multiple different parcels at the same time.", you can use this code:

            var url = "https://panel.sendcloud.sc/api/v2/labels/label_printer?ids=395012198,395012199";
            var label = await _apiV2.Label.Download(url);
            File.WriteAllBytes(@"C:\Temp\SendCloud_Retrieve_a_PDF_label_for_a_label_printer.pdf", label);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants