Table of Contents

Logtrade Connect API

Logtrade Connect provides REST based APIs built as a custom APIs in Business Central.

baseURL = https://api.businesscentral.dynamics.com/v2.0/<environmentName>/api/logtradeTechnology/logtradeConnect/v1.4/companies(<company id>)

Below are the endpoints and their supported methods described. Some methods are available both from the package object and the consignment object. Which is most appropriate to use depends on the use case. At the end of this page there's a sample scenraio based on the Rest Client for Visual Studio Code.

List Consignments


GET <baseURL>/consignments

Retrieves a list of consignments. Click here to learn more about consignments.

Response:

{   
    "value": [
        {
            "id": "8c0f2bfb-a156-ed11-9204-81099eab014a",
            "consignmentNo": "T-C2000611",
            "status": " ",
            "warehousePickNo": "",
            "warehouseShipmentNo": "",
            "inventoryPickNo": "",
            "sourceDocumentType": "Sales Order",
            "sourceDocumentNo": "800269",
            "sourceType": "Customer",
            "sourceNo": "10000",
            "shippingAgentServiceCode": "PACKAGE",
            "locationCode": "BLUE"
        }
    ]
}

Create Consignment


POST <baseURL>/consignments

Creates a consignment.

Note

This endpoint is "consignment centric", meaning that it mimics what the user can do in the web client using the consignment page. This means that packages can be automatically created if package lines are added to the consignment request and that items are fetched to the consignment based on "Qty. to Handle"/"Qty. to Ship" on source/pick document.

If you instead want use the package as your starting point to be able to specify items on packages etc., you should use the package endpoint described below. You can also combine these endpoints by starting with an empty consignment and then add packages using the package endpoint. If the package creation include items these items will replaced those initially created when the consignment was created. This workflow is used in the sample scenario at the end of this page.

Request:

{
    "inventoryPickNo": "",
    "warehousePickNo": "",
    "sourceDocumentType": "Sales Order",
    "sourceDocumentNo": "801130",
    "shippingAgentCode": "",
    "shippingAgentServiceCode": "",
    "printQueue": "",
    "packageLines": [
        {
            "noOfPackages": 2,
            "packageTypeCode": "LÅDA",
            "totalWeight": 3,
            "width": 0,
            "length": 0,
            "height": 0,
            "totalVolume": 0,
            "goodsTypeCode": "",
            "noteOfGoods": ""
        },
        {
            "noOfPackages": 1,
            "packageTypeCode": "LÅDA",
            "weight": 2,
            "width": 0,
            "length": 0,
            "height": 0,
            "totalVolume": 0,
            "goodsTypeCode": "",
            "noteOfGoods": ""
        }
    ]
}

The most simplistic use of this API can be as follows:

{
    "inventoryPickNo": "IP000001"
}

The above will create a consignment for the specified inventory pick and use defaults for number of packages, packet type code etc.

Response:

{    
    "bufferId": "a845d4fe-626b-ef11-9284-9900b5b79389",
    "consignmentId": "6a45d4fe-626b-ef11-9284-9900b5b79389",
    "consignmentNo": "T-C2002037",
    "inventoryPickNo": "",
    "warehousePickNo": "",
    "sourceDocumentType": "Sales Order",
    "sourceDocumentNo": "801130",
    "shippingAgentCode": "DHL",
    "shippingAgentServiceCode": "PAKET"
}

This endpoint also supports GET, but will then only show consignments created through the endpoint since it is based on buffer tables.

Bound actions

Confirm with Logtrade

POST <baseURL>/consignments(<bufferId>)/Microsoft.NAV.confirmConsignment

This action sends the consignment to Logtrade to get it confirmed with the default Confirm Status (prepare, release etc) on the consignment.

Note

It is the bufferId that shall be used when calling the action. Not the consignmentId.

Print

POST <baseURL>/consignments(<bufferId>)/Microsoft.NAV.printConsignment

This action sends the consignment to Logtrade for printing. This action is only used when automatic printing is turned off in Logtrade.

Goods types


GET <baseURL>/goodsTypes

Retrieves a list of goods types. Click here to learn more about goods types.

Response:

{
    "value": [
        {
            "id": "8cb8e59b-dcb3-ec11-91d2-b118644cbc91",
            "goodsTypeCode": "ITEMS",
            "description": "Items"
        }
    ]
}

Package types


GET <baseURL>/packageTypes

Retrieves a list of package types. Click here to learn more about package types.

Response:

{
    "value": [
        {
            "id": "8cb8e59b-dcb3-ec11-91d2-b118644cbc91",
            "packageTypeCode": "PALLET",
            "description": "Pallet"
        }
    ]
}

GET <baseURL>/printQueues

Retrieves a list of print queues. Click here to learn more about print queues.

Response:

{
    "value": [
        {
            "id": "8cb8e59b-dcb3-ec11-91d2-b118644cbc91",
            "printQueueName": "Standard",
            "description": "Standard"
        }
    ]
}

Shipping agents


GET <baseURL>/shippingAgents

Retrieves a list of shipping agents

Response:

{
    "value": [
        {
            "id": "5e542a48-df56-ee11-9247-a59b12c23cd3",
            "code": "DHL",
            "description": "DHL Systems, Inc.",
            "carrierName": "DhlSweden"
        }
    ]
}

Shipping agent services


GET <baseURL>/shippingAgentServices$filter=shippingAgentCode eq '<shipAgentCode>'

Retrieves a list of shipping agent services for a specified shipping agent (or all shipping agents)

Response:

{
    "value": [
        {
            "id": "cffa0daa-2dae-ec11-bb8e-000d3a220646",
            "shippingAgentCode": "DHL",
            "code": "PAKET",
            "description": "Paket",
            "carrierProductName": "DhlSweden_DhlPaket"
        }
    ]
}

Packages


GET <baseURL>/packages

Retrieves a list of packages. Click here to learn more about packages.

Note

This API is "package centric", meaning that the process starts with creating one or more packages and at the end of the process creating a consignment for these. Use this API when you want to report package by package and take control over which items belong to which package. If you want a more simplistic approach where you create the consignment and have items and packages added automatically to the consignment you should use the consignment API described above.

Response:

{
    "value": [
        {
            "id": "658d1c34-a156-ed11-9204-81099eab014a",
            "packageId": 2807,
            "externalId": ""
            "packageNo": "",
            "packageTypeCode": "PALLET",
            "goodsTypeCode": "ITEMS",
            "weight": 50,
            "packagingWeight": 15,
            "totalWeight": 65,
            "length": 1,
            "width": 1,
            "height": 0.5,
            "volume": 0.5,
            "packagingVolume": 0.16,
            "totalVolume": 0.66,
            "sourceDocumentType": "Sales Order",
            "sourceDocumentNo": "800267",
            "inventoryPickNo": "",
            "warehousePickNo": "",
            "consignmentNo": "T-C2000610",
            "customData1": "",
            "customData2": "",
            "customData3": "",
            "customData4": "",
            "customData5": ""
        }
    ]
}

POST <baseURL>/packages

Creates a package.

When a package is created through the API, all logic that is normally applied when working in the Business Central client is also applied. This means that if you e.g do not specify the weight of the package, the weight will be calculated based on items if you specify items in the request (or use the bound action GetItems to retrieve items to the packages based on a source document or pick document). The request sample below do not include all fields in the endpoint. Please refer to the table below for a full set of fields and descriptions.

Request:

{    
    "externalId": "",
    "packageNo": "",
    "packageTypeCode": "PALLET",    
    "goodsTypeCode": "ITEMS",    
    "sourceDocumentType": "Sales Order",
    "sourceDocumentNo": "800288",
    "inventoryPickNo": "",
    "warehousePickNo": "",
    "consignmentNo": "",
    "items": [
        {
            "itemNo": "70000",            
            "quantity": 2,            
            "sourceDocLineNo": 10000
        }
    ]
}
Field name Description
id The internal system ID of the package that can be used with the GET method to retrieve a specific package.
packageId The internal package ID in Logtrade Connect. This is a read only field
externalId An external identification that can be used to reference the package created in Business Central with corresponding data in the system that did the request.
packageNo The tracking number used by the carrier. This field normally get it's value when the consignment is sent to Logtrade for prepare or release.
packageTypeCode The code for the package type. Depending on how the package type is set up different logic can be triggered on the package (e.g. calculating weight and volume). Clich here to learn more about package types.
goodsTypeCode The goods type to use on the package. Click here to learn more about goods types.
weight The weight of the items of the package.
packagingWeight The weight of the packaging material (e.g. the pallet weight).
totalWeight The gross weight of the package.
length The package length.
width The package width.
volume The package volume.
packagingVolume The volume of the package material.
totalVolume The gross volume of the package.
sourceDocumentType The source document type. Valid values are:
-"Sales Order"
-"Sales Return Order"
-"Transfer Order"
-"Purchase Order"
-Purchase Return Order"
-Service Order"
-"Sales Shipment"
-"Transfer Shipment"
-"Purchase Return Shipment"
-"Service Shipment"
sourceDocumentNo The number of the source document.
inventoryPickNo The number of the inventory pick that the package refers to.
warehousePickNo The number of the warehouse pick that the package refers to.
consignmentNo The consignment number tha package shall be linked to when using the bound action addtoConsignment. If consignmentNo is not specified a consignment will be created or, if one single consignment exists for the source document, automatically chosen.
customData1
customData2
customData3
customData4
customData5
Any data that should be sent to Logtrade as custom data. This is mostly used for customized label layouts.
items You can either specify items when creating the package or call the bound action GetItems to have Logtrade Connect calculate which items to include on the package. When creating package for a pick document the column "Qty yo Package" is used. When creating package directly linked to a source document the column "Qty. to ship" is used for calculation. Please remember to set the location code on the package for tha latter scenario.
- itemNo
- variantCode
- description
- quantity
- lotNo
- serialNo
- expirationDate
- unitOfMeasureCode
- unitGrossWeight If not specified the gross weight will be fetched from the item.
- unitVolume If not specified the volume will be fetched from the item.
- sourceDocLineNo Specifies the source document linte number. This field is mandatory.

Response:

{
    "id": "a7417aa7-4a5b-ed11-9204-81099eab014a",
    "packageId": 2910,
    "packageNo": "",
    "packageTypeCode": "PALLET",
    "goodsTypeCode": "ITEMS",
    "weight": 8.52,
    "packagingWeight": 5,
    "totalWeight": 13.52,
    "length": 1,
    "width": 0.8,
    "height": 0.2,
    "volume": 0.14,
    "packagingVolume": 0.16,
    "totalVolume": 0.3,
    "sourceDocumentType": "Sales Order",
    "sourceDocumentNo": "800288",
    "inventoryPickNo": "",
    "warehousePickNo": "",
    "consignmentNo": ""
}

Bound actions

The endpoint /packages contains a number of bound actions that can be used after a package has been created. All actions perform the same logic as if their equivalents on the package page in the web GUI. So if you want to learn how these actions work, you can start by creating packages manually in Business Central and play around with the actions on the package page.

Add to consignment

POST <baseURL>/packages(<id>)/Microsoft.NAV.addPackageToConsignment

This action adds the packet to a consignment. If consignmentNo is not specified on the created package, a matching consignment for the pick or source document will be retrieved. If a matching consignment is not found, a consignment will be created. If there are more than one matching consignments an error will occur. This means that if you want to create e.g. four packages for a consignment, you can call apiAddToConsignment four times; The first call will create the consignment and the consecutive three will link the packages to the consignment created by the first package.

Response:

{
    "value": "<consignmentId>"
}

Remove from consignment

POST <baseURL>/packages(<id>)/Microsoft.NAV.removePackageFromConsignment

This action removes the packet from the consignment. The package will still exist, but no longer linked to the consignment. If the consignment number was specified ont the package that consignment number will still be there after the package has been removed from the consignment.

POST <baseURL>/packages(<id>)/Microsoft.NAV.printDeliveryPackageLabel

This action sends a print request to Logtrade for the package. Printing a delivery label requires that the packages is linked to a consignment and that the consignment is confirmed by Logtrade as a whole. Thus can this action trigger both sending the whole consignment to Logtrade and a print request to Logtrade for the individual package. If the package is not linked to a consignment the functionality described above for apiAddtoConsignment will first be executed. This action also supports continuous labelling, meaning that you can create packages and print delivery label as the packages are created.

Response:

{
    "value": "<consignmentId>"
}
POST <baseURL>/packages(<id>)/Microsoft.NAV.printCustomPackageLabel

This action prints a custom defined layout. Click here to learn more about custom layouts.

Request:

{
    "customLayoutCode": "<your layout code>",
    "printQueueName": ""
}

Confirm consignment

POST <baseURL>/packages(<id>)/Microsoft.NAV.confirmConsignment

This action sends the consignment of the specified package id to Logtrade for confirmation (prepare or release) using the print queue that is defined on the consignment. If you want to print to a specific print queue you can supply the print queue name in the request like this:

{
    "printQueueName": "[MySpecificPrintQueue]"
}

Get items

POST <baseURL>/packages(<id>)/Microsoft.NAV.getPackageItems

This action collects items for the pick document or source document that is specified on the package.

Sample scenario

This scenario is based on a sales order with one single item line. It uses the package type "EUR SSCC" which is setup for SSCC numbering. To run this example you need to install the REST Client extension in VS Code and create a sales order in Business Central. Then change the variables below to fit your data in BC.

@salesOrderNo = "801490"
@shippingAgentCode = "DHL"
@shippingAgentServiceCode = "PALL"
@packageType = "EUR SSCC"
@orderLineNo = 10000
@itemNo = "70000"
@itemQty = 10
@customLayoutCode = "SSCC"
@printQueueName = "Standard"

### Create consignment
# @name consignment
post {{apiURL}}/{{apiVersion}}/{{company}}/consignments
Content-Type: application/json
Authorization: {{dockerAuth}}

{
    "inventoryPickNo": "",
    "warehousePickNo": "",
    "sourceDocumentType": "Sales Order",
    "sourceDocumentNo": {{salesOrderNo}},
    "shippingAgentCode": {{shippingAgentCode}},
    "shippingAgentServiceCode": {{shippingAgentServiceCode}}
}

### Create package
# @name package
post {{apiURL}}/{{apiVersion}}/{{company}}/packages
Content-Type: application/json
Authorization: {{dockerAuth}}

{
    "packageTypeCode": {{packageType}},    
    "goodsTypeCode": "VAROR",
    "weight": 30,
    "packagingWeight": 0,
    "sourceDocumentType": "Sales Order",
    "sourceDocumentNo": {{salesOrderNo}},
    "consignmentNo": "{{consignment.response.body.consignmentNo}}",
    "items": [
        {
            "itemNo": {{itemNo}},
            "quantity": {{itemQty}},
            "sourceDocLineNo": {{orderLineNo}}
        }
    ]
}

### Add package to consignment
post {{apiURL}}/{{apiVersion}}/{{company}}/packages({{package.response.body.id}})/Microsoft.NAV.addPackageToConsignment
Content-Type: application/json
Authorization: {{dockerAuth}}

### Print SSCC-label
post {{apiURL}}/{{apiVersion}}/{{company}}/packages({{package.response.body.id}})/Microsoft.NAV.printCustomPackageLabel
Content-Type: application/json
Authorization: {{dockerAuth}}

{
    "customLayoutCode": {{customLayoutCode}},
    "printQueueName": {{printQueueName}}
}

### Confirm consignment with Logtrade to get carrier labels etc. printed
post {{apiURL}}/{{apiVersion}}/{{company}}/consignments({{consignment.response.body.bufferId}})/Microsoft.NAV.confirmConsignment
Authorization: {{dockerAuth}}