I create a Delivery Trip with three Delivery Stops as child documents. I am trying to update the Delivery Trip to indicate Delivery Stop as they are visited. However, I run into difficulties which go against what I was expecting
- The JSON document sent via API must have the same number of delivery_stops. If not, I get the error UpdateAfterSubmitError on delivery_stops. I thought the PUT verb would only be concerned with amending the specified stops and leave the rest as is?
- Once I include all delivery_stops in the Delivery Trip (3 in my test case), I start getting other errors, now at the Delivery Stop child document. First, it seems I must include “address” field in a child Delivery Stop document. If I don’t, I get MandatoryError. This is odd, because for each Delivery Stop, I am not interested in chaging the value of “address” already specified and it is PUT verb for the REST call anyway. Why do I need to specify the “address” field.
- Once I specify the “address” field for each Delivery Stop, I get an UpdateAfterSubmitError error for the fields “customer_address”, “customer”, “customer_contact” and “contact”. As I said, my only interest is to update the “visited” field and so I thought if I am using PUT, it is sufficient to specify just the “name” and “visited” fields for each Delivery Stop. Why do I have to specify the other fields, even though I am not changing their values?
The Minimal JSON I expected to work is:
{
“delivery_stops”: [
{
“name”: “3775918e42”,
“visited”: 1
}
]
}
Below is eventual document that I got to work (after including “mandatory” and fields that should not change after submit):
{
“delivery_stops”: [
{
“name”: “3775918e42”,
“address”: “Customer1-Shipping”,
“customer_address”: “10 Downing Street
London
\nUnited Kingdom
”,
“customer”: “Customer1”,
“customer_contact”: “”,
“contact”: “”,
“visited”: 1
},
{
“name”: “aab5252087”,
“address”: “Defo-Billing”,
“customer_address”: “Jesus Green
Cambridge
\nUnited Kingdom
\n”,
“customer”: “First Customer”,
“customer_contact”: " First Customer
+4420000000000",
“contact”: “First Customer-First Customer”,
“visited”: 0
},
{
“name”: “6ec4b7a9c8”,
“address”: “Customer2-Shipping”,
“customer_address”: “11 Downing Street
London
\nUnited Kingdom
”,
“customer”: “Customer2”,
“customer_contact”: “”,
“contact”: “”,
“visited”: 0
}
]
}