Creating a job without a package size via API

Hi Guys,

I have a brand new website that is intergrated with staurt to deliver food parcels across London. - Its going pretty well so far.

Even though all the packages will almost always be small enough for a motorbike, becuase some of my customers are far away. I have to create jobs with medium, large and some times xlarge package types.

My question is what is the most effective way to do this.

Currently I’m calling the API up to 3 times to create a job or get a price. Let me explain.

When a user enters an address on the website, I call the api starting with a small package size, then if the API returns a 200 response I know stuart will accept the booking, but if I get a 422 http response I call the api again this time with a medium package size… and so on… untill I get a 200 response.

If I go through all the package sizes and don’t get a 200 response then I give up and assume the address is out of range.

My Question is… Is this the best way to handel this?
Is there a way I can work out for certain what package size I can use for an address?
Or send a request with out a package size and the API decide based on distance?

I’m based in the UK, can I specify a transport type? rather than a package size? from what I can see in the C# client API that only applies to france, is that true?

Its just that I have to call the API many times to effectively do one operation.

Any ideas? -

Hello Ayo,

We are happy to know your brand new website is going pretty well! Thank you for your complete message.

The problem your are describing is actually linked to the maximum distance constraint of the transport type that will, at the end, handle the delivery. You can find all the details in these two articles:

https://help-client.stuart.com/en/articles/128417-understanding-package-size
https://help-client.stuart.com/en/articles/3183505-maximum-pick-up-to-drop-off-distance

The best way to handle this is actually to request our Validate Job parameters endpoint and treat the different 422 errors you can get back. There are several possibilities described here.
Doing so you would be able to differentiate between the following 422 errors:

  • OUT_OF_RANGE
  • JOB_DISTANCE_NOT_ALLOWED

and you wouldn’t need to assume why it failed.

Or send a request with out a package size and the API decide based on distance?
I’m based in the UK, can I specify a transport type? rather than a package size? from what I can see in the C# client API that only applies to france, is that true?

One of [package_type,transport_type] is absolutely required. In the UK you can use the package_type which allow us to cross dispatch on different transport types which is better for you in your case.

Its just that I have to call the API many times to effectively do one operation.

If you already know the distance (or cap the eligibility of the delivery service on your side) you should be able to do it in a single callI. Otherwise I would suggest you to use our validation endpoint to validate all the attributs and then call the Job creation endpoint only once.

Hope it brings you some answers and don’t hesitate if you have any other questions.

Best Regards,

Thanks Paul.

At first glance using the Validation end point seems like a good idea. But I still have the same problem really. I would call the validation end point… initally with package size of small… if I get back distance to far then I would have to call it again, and again untill I had the right size. Then create the job.

I think, ill leave it as it is at the moment, and come to it a bit later when I have worked on some other more pressing issues.

Thanks
Ayo

You’re welcome!

You are totally right, just adding that in the worst case you will have to do two calls to determine the right size in the UK based on the information in the above “Understanding Package Size” article since the cross dispatch is split in only two groups.

Have a good day!