Skip to main content

Notifications

Small and medium business | Business Central, N...
Unanswered

OData V4 Web Service Expansion

Posted on by 29

Hello, I have Developed multiple Custom APIs to receive Documents and respective Lines. Orders/Shipments/Credits. The data is inserted into one single table if that information is of any help. However, At times, without any changes to the code (API Pages), the Line Property just disappears. I have no better way of saying it. I get the following response 'The property 'shipmentLines' does not exist on type 'Microsoft.NAV.easyShipment'. Make sure to only use property names that are defined by the type. CorrelationId: 18a70822-cc72-4c56-8c48-2a5df03678e8. ' It reappears once we redeploy.

The $metadata (yourbaseurl:port/(ServerInstance)/api/(APIPublisher)/(APIGroup)/(APIVersion)/$metadata) response will show it as:

            <EntityType Name="easyShipment">
                <Key>
                    <PropertyRef Name="id" />
                </Key>
                <Property Name="id" Type="Edm.Guid" Nullable="false" />
                <Property Name="documentNo" Type="Edm.String" MaxLength="30" />
                <Property Name="customerComments" Type="Edm.String" MaxLength="100" />
                <Property Name="customerEmail" Type="Edm.String" MaxLength="80" />
                <Property Name="customerID" Type="Edm.String" MaxLength="20" />
                <Property Name="weight" Type="Edm.Decimal" Scale="Variable" />
                <Property Name="dateTime" Type="Edm.DateTimeOffset" />
                <Property Name="discountAmount" Type="Edm.Decimal" Scale="Variable" />
                <Property Name="discountCode" Type="Edm.String" MaxLength="20" />
                <Property Name="grandTotal" Type="Edm.String" MaxLength="20" />
                <Property Name="indexNo" Type="Edm.String" MaxLength="20" />
                <Property Name="type" Type="Edm.String" />
                <Property Name="orderExists" Type="Edm.Boolean" />
                <Property Name="orderID" Type="Edm.String" MaxLength="20" />
                <Property Name="paymentMethod" Type="Edm.String" MaxLength="100" />
                <Property Name="receipted" Type="Edm.DateTimeOffset" />
                <Property Name="shipmentCount" Type="Edm.Int32" />
                <Property Name="shipmentDate" Type="Edm.Date" />
                <Property Name="shipmentID" Type="Edm.String" MaxLength="100" />
                <Property Name="shippingHandling" Type="Edm.Decimal" Scale="Variable" />
                <Property Name="shippingDescription" Type="Edm.String" MaxLength="250" />
                <Property Name="shippingMethod" Type="Edm.String" MaxLength="100" />
                <Property Name="store" Type="Edm.String" MaxLength="100" />
                <Property Name="subtotal" Type="Edm.Decimal" Scale="Variable" />
                <Property Name="totalNoOfLines" Type="Edm.Int32" />
                <Property Name="isOrderCompletelySynced" Type="Edm.Boolean" />
                <Property Name="isShopOrder" Type="Edm.Boolean" />
                <Property Name="dimensionCode" Type="Edm.String" MaxLength="20" />
</EntityType>
Once we Redeploy, it will be shown as (which is how it should be):
            <EntityType Name="easyShipment">
                <Key>
                    <PropertyRef Name="id" />
                </Key>
                <Property Name="id" Type="Edm.Guid" Nullable="false" />
                <Property Name="documentNo" Type="Edm.String" MaxLength="30" />
                <Property Name="customerComments" Type="Edm.String" MaxLength="100" />
                <Property Name="customerEmail" Type="Edm.String" MaxLength="80" />
                <Property Name="customerID" Type="Edm.String" MaxLength="20" />
                <Property Name="weight" Type="Edm.Decimal" Scale="Variable" />
                <Property Name="dateTime" Type="Edm.DateTimeOffset" />
                <Property Name="discountAmount" Type="Edm.Decimal" Scale="Variable" />
                <Property Name="discountCode" Type="Edm.String" MaxLength="20" />
                <Property Name="grandTotal" Type="Edm.String" MaxLength="20" />
                <Property Name="indexNo" Type="Edm.String" MaxLength="20" />
                <Property Name="type" Type="Edm.String" />
                <Property Name="orderExists" Type="Edm.Boolean" />
                <Property Name="orderID" Type="Edm.String" MaxLength="20" />
                <Property Name="paymentMethod" Type="Edm.String" MaxLength="100" />
                <Property Name="receipted" Type="Edm.DateTimeOffset" />
                <Property Name="shipmentCount" Type="Edm.Int32" />
                <Property Name="shipmentDate" Type="Edm.Date" />
                <Property Name="shipmentID" Type="Edm.String" MaxLength="100" />
                <Property Name="shippingHandling" Type="Edm.Decimal" Scale="Variable" />
                <Property Name="shippingDescription" Type="Edm.String" MaxLength="250" />
                <Property Name="shippingMethod" Type="Edm.String" MaxLength="100" />
                <Property Name="store" Type="Edm.String" MaxLength="100" />
                <Property Name="subtotal" Type="Edm.Decimal" Scale="Variable" />
                <Property Name="totalNoOfLines" Type="Edm.Int32" />
                <Property Name="isOrderCompletelySynced" Type="Edm.Boolean" />
                <Property Name="isShopOrder" Type="Edm.Boolean" />
                <Property Name="dimensionCode" Type="Edm.String" MaxLength="20" />
                <NavigationProperty Name="shipmentLines" Type="Collection(Microsoft.NAV.shipmentLine)" ContainsTarget="true" />
            </EntityType>
            <EntityType Name="shipmentLine">
                <Key>
                    <PropertyRef Name="id" />
                </Key>
                <Property Name="id" Type="Edm.Guid" Nullable="false" />
                <Property Name="calculatorSettings" Type="Edm.String" MaxLength="250" />
                <Property Name="dateTime" Type="Edm.DateTimeOffset" />
                <Property Name="discountAmount" Type="Edm.Decimal" Scale="Variable" />
                <Property Name="type" Type="Edm.String" />
                <Property Name="lineType" Type="Edm.String" />
                <Property Name="name" Type="Edm.String" MaxLength="200" />
                <Property Name="orderID" Type="Edm.String" MaxLength="20" />
                <Property Name="productOptions" Type="Edm.String" MaxLength="100" />
                <Property Name="qTY" Type="Edm.Decimal" Scale="Variable" />
                <Property Name="receipted" Type="Edm.DateTimeOffset" />
                <Property Name="shipmentID" Type="Edm.String" MaxLength="100" />
                <Property Name="shippingHandling" Type="Edm.Decimal" Scale="Variable" />
                <Property Name="size" Type="Edm.String" MaxLength="100" />
                <Property Name="sku" Type="Edm.String" MaxLength="20" />
                <Property Name="subtotal" Type="Edm.Decimal" Scale="Variable" />
                <Property Name="webshopLineNo" Type="Edm.Int32" />
            </EntityType>
Lastly Even if the Line Property is there in the response. Sometime the Lines would not be received. This happens only on specific Server instances. I do not know if some type of conf is causing this. It works fine on one server and stops receiving lines on the other. The .app on both servers is the same. Even if there are some changes, the API pages are not changed and are exactly the same.
All 3 APIs are structured the same but the line issue is received only on Shipment API. Orders and Credits work fine.
Screenshot of the example code as Shipment API:
pastedimage1683890473780v2.png
pastedimage1683890518006v3.png
Url Struct:
Baseurl:port/(ServerInstance)/api/(APIPublisher)/(APIGroup)/(APIVersion)/$batch
Request Body:
{
    "requests": [
        {
            "method": "POST",
            "id": "r1",
            "url": "companies(CompanyID)/easyShipments?$expand=shipmentLines",
            "headers": {
                "Content-Type": "application/json"
            },
            "body": {
                "documentNo": "PM-TESTSHP3",
                "dimensionCode": "ABC",
                "shipmentDate": "2021-09-21",
                "shipmentID": "PM-TESTSHP1",
                "store": "Store",
                "orderID": "PM-TESTORD2",
                "weight": 24.28,
                "type": "Insert",
                "shippingDescription": "Ship",
                "shippingMethod": "Ship Method",
                "shippingHandling": 0,
                "customerID": "Cust",
                "customerEmail": "Cust@Email.co.uk",
                "paymentMethod": "Cash",
                "dateTime": "2023-02-15T12:17:54Z",
                "totalNoOfLines": 1,
                "isShopOrder": true,
                "shipmentLines": [
                    {
                        "name": "TSTItem",
                        "sku": "TST",
                        "size":"",
                        "qTY": 1,
                        "shipmentID": "PM-TESTSHP3",
                        "orderID": "PM-TESTORD2"
                    }
                ]
            }
        }
    ]
}
Response:
{
    "responses": [
        {
            "id": "r1",
            "status": 201,
            "headers": {
                "location": "https://YourBaseURL:Port/(ServerInstance)/api/(APIPublisher)/(APIGroup)/v2.0/companies(9848fdb3-4041-eb11-bbfc-000d3ad4efad)/easyShipments(ecf7af9b-aef0-ed11-964f-0022480177a4)",
                "content-type": "application/json; odata.metadata=minimal",
                "odata-version": "4.0"
            },
            "body": {
                "@odata.context": "https://YourBaseURL:Port/(ServerInstance)/api/(APIPublisher)/(APIGroup)/v2.0/$metadata#companies(9848fdb3-4041-eb11-bbfc-000d3ad4efad)/easyShipments/$entity",
                "@odata.etag": "W/\"JzQ0OzBhL1k2cTFkZk9oZG43K1MrbGZ4ZnFWR2NoOE1uSmI5S0pMajhhK1BuQnc9MTswMDsn\"",
                "id": "ecf7af9b-aef0-ed11-964f-0022480177a4",
                "documentNo": "PM-TESTSHP2",
                "customerComments": "",
                "customerEmail": "Cust@email.co.uk",
                "customerID": "Cust",
                "weight": 24.28,
                "dateTime": "2023-02-15T12:17:54Z",
                "discountAmount": 0,
                "discountCode": "",
                "grandTotal": "",
                "indexNo": "",
                "type": "Insert",
                "orderExists": false,
                "orderID": "PM-TESTORD2",
                "paymentMethod": "CASH",
                "receipted": "2023-05-12T10:20:25.533Z",
                "shipmentCount": 0,
                "shipmentDate": "2021-09-21",
                "shipmentID": "PM-TESTSHP1",
                "shippingHandling": 0,
                "shippingDescription": "Ship",
                "shippingMethod": "Ship Method",
                "store": "Store",
                "subtotal": 0,
                "totalNoOfLines": 1,
                "isOrderCompletelySynced": false,
                "isShopOrder": true,
                "dimensionCode": "TST",
                "shipmentLines": []
            }
        }
    ]
}
Feel free to ask anymore detail.
 
  • abhaq5000 Profile Picture
    abhaq5000 15 on at
    RE: OData V4 Web Service Expansion

    hello

    can you see my problem

    community.dynamics.com/.../1342890

    do you have any idea

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,232 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,064 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans