Creating a new task with requested barcodes

Creating a new task with requested barcodes

The following request creates a new task with one mandatory and one optional barcode.

curl -X POST "https://onfleet.com/api/v2/tasks" \
       -u "cd3b3de84cc1ee040bf06512d233719c:" \
       -d '{"destination":{...},
            "recipients":[...],
            "scanOnlyRequiredBarcodes": true,
            "barcodes":[
                {"data":"aGVsbG8gd29ybGQh","blockCompletion":true},
                {"data":"aG93IGFyZSB5b3U/"}
             ]
            }'
{
  "id": "0VuO6yDq5YrGeZ7NVwUqK8hu",
  //...,
  "barcodes": {
    "required": [ 
      { "data": "aGVsbG8gd29ybGQh", "blockCompletion": true },
      { "data": "aG93IGFyZSB5b3U/", "blockCompletion": false }
    ],
    "captured": [ ]
  },
  //... 
}

❗️

What you see is NOT what you get

If your request was successful, the API will respond with your barcodes under the property of barcodes.required, it does not mean that you can set the barcode properties the same way it's provided by the API.

📘

Use of scanOnlyRequiredBarcodes

Use the boolean flag of scanOnlyRequiredBarcodes upon task creation to restrict the scanning of non-required barcodes. Learn more about the usage here.