API - Inventory Items


Overview

The API returns the inventory of Items. Data cannot be changed directly through this API, but inventory can be moved between locations (and bins) with the procedures described under Procedures below.

The endpoint contains all items of type Inventory, both standard items and Wisefish trade items, blocked and non-blocked. The key is the item number (number), so a single item is read with GET .../inventoryItems('<Item No.>'). Use locationFilter in $filter to get the inventory of one location; inventory and tradeItemInventory are then calculated for that location only.

Endpoint name

inventoryItems

Source table

Item

Fixed view

Type = Inventory

Requests allowed

GET (inventory changes via procedures)

Primary key

number

Record ID

number

Procedures

transferQtyToLocation, transferQtyToLocationAndBin


Data

Field List

Property

Type

Format

Description


1

number

string

max 20

Item No.

Record ID

primary key

2

description

string

max 100

Item Description


3

packageDescription

string

max 30

Package Description


4

tradeItemType

string

enum

Blank if it is a standard item, if not blank, it is a “trade item”. Options:

  • blank - standard item, can be used if it is not seafood, for example packaging

  • Product

  • Raw Material

  • WIP - produced material that will be used as a consumption for products


5

locationFilter

string

max 10

Location Filter. Use in $filter to get the inventory of one location


6

inventory

number

decimal

Inventory (in base unit of measure; respects locationFilter)


7

baseUnitOfMeasure

string

max 10

Base Unit of Measure


8

tradeItemInventory

number

decimal

Inventory (in the trade item base unit of measure; respects locationFilter)


9

tradeItemUnitOfMeasure

string

max 10

Trade Item Unit of Measure


Object Example

JSON
{
    "number": "1.056",
    "description": "Carton sticker 95x100mm ",
    "packageDescription": "",
    "tradeItemType": " ",
    "locationFilter": "",
    "inventory": 14891,
    "baseUnitOfMeasure": "STK",
    "tradeItemInventory": 0,
    "tradeItemUnitOfMeasure": ""
}

Procedures

Procedures are called on a specific item: POST inventoryItems('<Item No.>')/Microsoft.NAV.<procedureName> with a JSON body of parameters. Each procedure returns a text on success. On failure it returns an error with a readable message.

Procedure

Parameters

Description

Details

transferQtyToLocation

quantity (decimal), lotNumber (text, max 20), fromLocation (text, max 10), toLocation (text, max 10)

Post an item transfer of a quantity (in base unit of measure) of a standard item from one location to another.

Show more

transferQtyToLocationAndBin

quantity (decimal), lotNumber (text, max 20), fromLocation (text, max 10), toLocation (text, max 10), toBin (text, max 20)

Same as transferQtyToLocation, but also sets the bin on the destination location.

Show more

Parameter names are case-sensitive. All parameters must be present in the body, but an optional parameter may be sent as an empty string ("").

Transfer quantity to another Location

The procedure transferQtyToLocation posts an item transfer (an item journal line with entry type Transfer and today as posting date) of a quantity of the item from one location to another. The quantity is in the item's base unit of measure.

This procedure only works for standard items (tradeItemType is blank). For Wisefish trade items the call fails with the error: “This procedure has not been implemented! Instead, a MES transaction can be used.”

JSON
POST
.../inventoryItems([record-id])/Microsoft.NAV.transferQtyToLocation

Body:
{
    "quantity": [quantity in base unit of measure],
    "lotNumber": [lot number, or "" if the item is not lot tracked],
    "fromLocation": [code of the location to move from],
    "toLocation": [code of the location to move to]
}

Parameters

Type

Max Len

Description


quantity

decimal


The quantity to transfer, in the item's base unit of measure.

mandatory

lotNumber

string

20

The lot to transfer. Send "" if the item is not lot tracked.

optional

fromLocation

string

10

The location code to move the quantity from.

mandatory

toLocation

string

10

The location code to move the quantity to.

mandatory

The transfer is posted, and the value property of the response is Success.

Possible errors:

  • The item does not exist, i.e. no item with the given Record ID (standard Business Central error, record not found).

  • For Wisefish trade items (tradeItemType not blank): This procedure has not been implemented! Instead, a MES transaction can be used.

  • No item journal template of type Transfer, or no non-recurring batch in it, is found, or the batch has no No. Series (standard Business Central errors).

  • Validation errors on the item, the locations or the quantity, for example a location that does not exist (standard Business Central errors).

  • Posting errors (standard Business Central errors), for example insufficient inventory of the item (or lot) on fromLocation, or a missing lot number for a lot-tracked item.

Behaviour notes:

  • The transfer is posted directly; no journal line is left in the item journal. The document no. is the next number from the No. Series of the transfer journal batch.

  • If lotNumber is not empty, the lot is transferred as the same lot (lot no. and new lot no. are both lotNumber).

  • No bin is set on the destination. Use transferQtyToLocationAndBin to move the quantity to a specific bin.


Transfer quantity to another Location and Bin

The procedure transferQtyToLocationAndBin works the same way as transferQtyToLocation, but additionally takes the bin on the destination location that the quantity is moved to.

This procedure only works for standard items (tradeItemType is blank). For Wisefish trade items the call fails with the error: “There are no standard Bins on inventory for Wisefish Trade Items!”

JSON
POST
.../inventoryItems([record-id])/Microsoft.NAV.transferQtyToLocationAndBin

Body:
{
    "quantity": [quantity in base unit of measure],
    "lotNumber": [lot number, or "" if the item is not lot tracked],
    "fromLocation": [code of the location to move from],
    "toLocation": [code of the location to move to],
    "toBin": [code of the bin on the destination location]
}

Parameters

Type

Max Len

Description


quantity

decimal


The quantity to transfer, in the item's base unit of measure.

mandatory

lotNumber

string

20

The lot to transfer. Send "" if the item is not lot tracked.

optional

fromLocation

string

10

The location code to move the quantity from.

mandatory

toLocation

string

10

The location code to move the quantity to.

mandatory

toBin

string

20

The bin on the destination location (toLocation) to move the quantity to. If sent as "", no bin is set on the destination.

optional

The transfer is posted, and the value property of the response is Success.

Possible errors:

  • The item does not exist, i.e. no item with the given Record ID (standard Business Central error, record not found).

  • For Wisefish trade items (tradeItemType not blank): There are no standard Bins on inventory for Wisefish Trade Items!

  • No item journal template of type Transfer, or no non-recurring batch in it, is found, or the batch has no No. Series (standard Business Central errors).

  • Validation errors on the item, the locations or the quantity, for example a location that does not exist (standard Business Central errors).

  • The bin toBin does not exist on toLocation (standard Business Central error).

  • Posting errors (standard Business Central errors), for example insufficient inventory of the item (or lot) on fromLocation, or a missing lot number for a lot-tracked item.

Behaviour notes:

  • The transfer is posted directly; no journal line is left in the item journal. The document no. is the next number from the No. Series of the transfer journal batch.

  • If lotNumber is not empty, the lot is transferred as the same lot (lot no. and new lot no. are both lotNumber).

  • There is no parameter for the bin the quantity is moved from; only the destination bin is set by the procedure.


Examples

Read inventory

Read the inventory of one item

Reads one item by its Record ID (number). The response is one inventory item object.

Request:

JSON
GET .../inventoryItems('1000')

Response:

JSON
{
    "@odata.context": "https://containers.wisefish.com/BC/api/wisefish/base/v1.0/$metadata#inventoryItems/$entity",
    "@odata.etag": "W/\"JzIwOzExODYyNTAwNTc4ODk2MDkwMjEzMTswMDsn\"",
    "number": "1000",
    "description": "Þorsklifur - ósnyrt",
    "packageDescription": "1 x 1",
    "tradeItemType": "Product",
    "locationFilter": "",
    "inventory": 2989.11,
    "baseUnitOfMeasure": "KG",
    "tradeItemInventory": 299,
    "tradeItemUnitOfMeasure": "KAR"
}

Inventory for specific Location

To get the inventory on Location BLUE this request will do:

JSON
GET ../inventoryItems?$filter=locationFilter eq 'BLUE'

The response could be like below:

Expand to see the example json
JSON
{
    "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/b33a6a3b-244c-4295-84b3-0ad90823c736/AB_Test_191125/api/wisefish/base/v1.0/$metadata#companies(1691e98a-6a95-f011-b41a-6045bde126e9)/inventoryItems",
    "value": [
        {
            "@odata.etag": "W/\"JzE4OzExOTg3Mjk2Njc0NTg4MTcxNTE7MDA7Jw==\"",
            "number": "1.056",
            "description": "Carton sticker 95x100mm ",
            "packageDescription": "",
            "tradeItemType": " ",
            "locationFilter": "BLUE",
            "inventory": 14891,
            "baseUnitOfMeasure": "STK",
            "tradeItemInventory": 0,
            "tradeItemUnitOfMeasure": ""
        },
        {
            "@odata.etag": "W/\"JzE5OzI1NzEzMDY1NjU5NDM1ODg4OTIxOzAwOyc=\"",
            "number": "1.057",
            "description": "Display sticker 23x32",
            "packageDescription": "",
            "tradeItemType": " ",
            "locationFilter": "BLUE",
            "inventory": 0,
            "baseUnitOfMeasure": "STK",
            "tradeItemInventory": 0,
            "tradeItemUnitOfMeasure": ""
        },
        {
            "@odata.etag": "W/\"JzIwOzExODYyNTAwNTc4ODk2MDkwMjEzMTswMDsn\"",
            "number": "1000",
            "description": "Þorsklifur - ósnyrt",
            "packageDescription": "1 x 1",
            "tradeItemType": "Product",
            "locationFilter": "BLUE",
            "inventory": 2989.11,
            "baseUnitOfMeasure": "KG",
            "tradeItemInventory": 299,
            "tradeItemUnitOfMeasure": "KAR"
        },
        {
            "@odata.etag": "W/\"JzIwOzE3NjQzNDM1Mjc5MDgxMjQ5NDMzMTswMDsn\"",
            "number": "1001",
            "description": "Afskurður - forsnyrting",
            "packageDescription": "1 x 0",
            "tradeItemType": "Product",
            "locationFilter": "BLUE",
            "inventory": 100,
            "baseUnitOfMeasure": "KG",
            "tradeItemInventory": 10,
            "tradeItemUnitOfMeasure": "KAR"
        }
  ]
}


Read products on one location

Combines filters to get only trade items of type Product on location BLUE. The response is a list of inventory item objects, as in the example above.

JSON
GET .../inventoryItems?$filter=tradeItemType eq 'Product' and locationFilter eq 'BLUE'

Transfer inventory

Transfer 10 units from BLUE to GREEN

Moves 10 units (base unit of measure) of the standard item 70064 from location BLUE to GREEN using transferQtyToLocation.

JSON
POST .../inventoryItems('70064')/Microsoft.NAV.transferQtyToLocation
{
    "quantity": 10,
    "lotNumber": "",
    "fromLocation": "BLUE",
    "toLocation": "GREEN"
}

Response:
{
    "@odata.context": "https://containers.wisefish.com/BC/api/wisefish/base/v1.0/$metadata#Edm.String",
    "value": "Success"
}

Transfer a lot from BLUE to GREEN

Moves 25 units of lot LOT0044 of the lot-tracked standard item 70064 from location BLUE to GREEN using transferQtyToLocation.

Request:

JSON
POST
.../inventoryItems('70064')/Microsoft.NAV.transferQtyToLocation

Body:
{
    "quantity": 25,
    "lotNumber": "LOT0044",
    "fromLocation": "BLUE",
    "toLocation": "GREEN"
}

Response:

JSON
{
    "@odata.context": "https://containers.wisefish.com/BC/api/wisefish/base/v1.0/$metadata#Edm.String",
    "value": "Success"
}

Transfer 10 units from BLUE to bin A-01 on GREEN

Moves 10 units of the standard item 70064 from location BLUE to bin A-01 on location GREEN using transferQtyToLocationAndBin.

JSON
POST .../inventoryItems('70064')/Microsoft.NAV.transferQtyToLocationAndBin
{
    "quantity": 10,
    "lotNumber": "",
    "fromLocation": "BLUE",
    "toLocation": "GREEN",
    "toBin": "A-01"
}

Response:
{
    "@odata.context": "https://containers.wisefish.com/BC/api/wisefish/base/v1.0/$metadata#Edm.String",
    "value": "Success"
}