Job can’t be canceled, why?

HI

We have an Error to the cancel job.
Can you help us, please?

I have created a job:

Result:
<201 Created,
{Date=[Mon, 03 Sep 2018 15:38:58 GMT],
Content-Type=[application/json], Content-Length=[1803], Connection=[keep-alive],
Status=[201 Created],
Cache-Control=[max-age=0, private, must-revalidate], Vary=[Origin], X-DailyRateLimit-Limit=[43200],
X-MinuteRateLimit-Identifier=[ratelimit:51.68.47.116:2018-09-03-15-38],
X-DailyRateLimit-Remaining=[35090], X-Request-Id=[9734a0b2-692f-4141-98d8-c0b40a230739], X-MinuteRateLimit-Limit=[500], X-MinuteRateLimit-Remaining=[422],
X-DailyRateLimit-Identifier=[ratelimit:51.68.47.116:2018-09-03],
ETag=[W/“5295ae3164a9b52b1524fa5b8d497efb”], X-Runtime=[2.163862], Server=[nginx + Phusion Passenger]}

{
“id”:109112,
“created_at”:“2018-09-03T17:38:57.061+02:00”,
“status”:“searching”,
“package_type”:null,
“transport_type”:“motorbike”,
“assignment_code”:null,
“dropoff_at”:null,
“pickup_at”:null,
“ended_at”:null,
“comment”:null,
“distance”:0.358,
“duration”:2,
“traveled_time”:0,
“traveled_distance”:0,
“deliveries”:[
{
“id”:109299,
“status”:“pending”,
“picked_at”:null,
“delivered_at”:null,
“tracking_url”:“https://stuart.sandbox.followmy.delivery/109299/30df4caaa095e6700c87fc7c7d961fc9”,
“client_reference”:null,
“package_description”:null,
“package_type”:null,
“package_image_url”:null,
“pickup”:{
“id”:1310074,
“latitude”:40.412206,
“longitude”:-3.660589,
“comment”:“Preguntar por Rodolf”,
“address”:{
“street”:“Calle del Camino de los Vinateros s/n”,
“postcode”:“28017”,
“city”:“Madrid”,
“zone”:“madrid”,
“country”:“Spain”,
“formatted_address”:“Calle del Camino de los Vinateros s/n, 28017, Madrid, Spain”
},
“contact”:{
“firstname”:“Encagardo”,
“lastname”:“Rodolf”,
“company_name”:“Rodol Moratalaz”,
“phone”:“+34914376012”,
“email”:“email”
},
“access_codes”:[

        ]
     },
     "dropoff":{
        "id":1310075,
        "latitude":40.4118581,
        "longitude":-3.6583601,
        "comment":"piso 2, puerta izq.",
        "address":{
           "street":"Calle del Corregidor Diego de Valderrabano 25",
           "postcode":"28030",
           "city":"Madrid",
           "zone":"madrid",
           "country":"Spain",
           "formatted_address":"Calle del Corregidor Diego de Valderrabano 25, 28030, Madrid, Spain"
        },
        "contact":{
           "firstname":"Raul",
           "lastname":null,
           "company_name":null,
           "phone":"+34654666999",
           "email":null
        },
        "access_codes":[

        ]
     },
     "cancellation":{
        "canceled_by":null,
        "reason_key":null,
        "comment":null
     },
     "eta":{
        "pickup":null,
        "dropoff":null
     },
     "proof":{
        "signature_url":null
     }
  }

],
“driver”:null,
“pricing”:{
“currency”:“EUR”,
“tax_percentage”:0.21,
“price_tax_included”:6.66,
“price_tax_excluded”:5.5,
“tax_amount”:1.16,
“invoice_url”:null
},
“rating”:null
}

i exceute cancelJob service

https://sandbox-api.stuart.com/v2/jobs/109112/cancel

and result is …

{“error”:“CANCELLATION_ERROR”,“message”:“Job can’t be canceled”}

Hi @carlosMshop,

This error means that you cannot cancel the job. Please have a look at the following topic How does cancellation works? to understand the cancellation mechanism.

Notice that you are not allowed to cancel with the cancel a Job endpoint after the driver picked the package. In the sandbox environment the pickup usually happens really fast.

hi

I want cancel this Job 109270
Now this Job is in staus In Progress
why does it return this error ?

…v2/jobs/109270/cancel
POST request for “cancel” resulted in 422 (Unprocessable Entity); invoking error handler

errorResponse CancelStuart: {“error”:“CANCELLATION_ERROR”,“message”:“Job can’t be canceled”}

Hi,

If the driver already picked up the package then you are not allowed to cancel the job (see my answer just above).I confirm you that this is the expected behaviour. In production you will need to contact the Stuart Support Team in that case.

OK. In test , How can we do to simulate a cancellation?

thanks

You’re welcome,
to simulate a cancellation you can try to do it very quickly (before pickup) or you can easily schedule a job for later on so you have time to cancel it.

We can also plan a call to do end-to-end tests and simulate this case together if needed.

OK,

We are doing the test, quickly.

First, create a job. and immediately afterwards we generated the cancellation.
But, the result is the same.

We want to go through several states and cancel it them

is it posible?

thanks

Best way to do that will be to synchronise so we can simulate this together. Let me pm you to find the best time for that.