Deepinserts not working
jordi79
Member Posts: 281
I have been trying to create an api page with subpage that allows deepinserts, but have failed in doing so. I have seen many other working examples, but could not get mine to work. I have been looking at https://github.com/manjusree16/AL-Demos/blob/master/CustomAPIorderExample/Table/Call_API.http and was able to duplicate his work. But when I try to do the same on a SalesInvoice, I fail to do so.
My code:
POST request
My code:
page 50715 apigrpSalesInv
{
APIGroup = 'apigrp';
APIPublisher = 'apipub';
APIVersion = 'v2.0';
ApplicationArea = All;
Caption = 'apigrpSalesInv', Locked = true;
DelayedInsert = true;
EntityName = 'apigrpSalesInv';
EntityCaption = 'apigrpSalesInv', Locked = true;
EntitySetName = 'apigrpSalesInvs';
EntitySetCaption = 'apigrpSalesInvs', Locked = true;
PageType = API;
SourceTable = "Sales Header";
SourceTableView = where("Document Type" = FILTER(Invoice));
ODataKeyFields = "No.";
Extensible = false;
ChangeTrackingAllowed = true;
layout
{
area(Content)
{
repeater(General)
{
field(no; Rec."No.")
{
Caption = 'No.';
}
field(sellToCustomerNo; Rec."Sell-to Customer No.")
{
Caption = 'Sell-to Customer No.';
}
field(postingDate; Rec."Posting Date")
{
Caption = 'Posting Date';
}
part(apigrpSalesInvLines; apigrpSalesInvLine)
{
ApplicationArea = All;
Caption = 'apigrpSalesInvLines', Locked = true;
EntityName = 'apigrpSalesInvLine';
EntitySetName = 'apigrpSalesInvLines';
SubPageLink = "Document Type" = field("Document Type"), "Document No." = field("No.");
//Multiplicity = Many;
}
}
}
}
}
page 50714 apigrpSalesInvLine
{
APIGroup = 'apigrp';
APIPublisher = 'apipub';
APIVersion = 'v2.0';
ApplicationArea = All;
Caption = 'apigrpSalesInvLine', Locked = true;
DelayedInsert = true;
EntityName = 'apigrpSalesInvLine';
EntityCaption = 'apigrpSalesInvLine', Locked = true;
EntitySetName = 'apigrpSalesInvLines';
EntitySetCaption = 'apigrpSalesInvLines', Locked = true;
PageType = API;
UsageCategory = Lists;
//PageType = ListPart;
SourceTable = "Sales Line";
SourceTableView = where("Document Type" = FILTER(Invoice));
ODataKeyFields = "Document Type", "Document No.", "Line No.";
Extensible = false;
ChangeTrackingAllowed = true;
InsertAllowed = true;
AutoSplitKey = true;
PopulateAllFields = true;
layout
{
area(Content)
{
repeater(General)
{
field(documentType; Rec."Document Type")
{
ToolTip = 'Specifies the type of document that you are about to create.';
}
field(documentNo; Rec."Document No.")
{
Caption = 'Document No.';
}
field(lineNo; Rec."Line No.")
{
Caption = 'Line No.';
}
field("type"; Rec."Type")
{
Caption = 'Type';
}
field(no; Rec."No.")
{
Caption = 'No.';
}
field(description; Rec.Description)
{
Caption = 'Description';
}
field(quantity; Rec.Quantity)
{
Caption = 'Quantity';
}
field(unitPrice; Rec."Unit Price")
{
Caption = 'Unit Price';
}
}
}
}
}
POST request
POST /BC/api/apipub/apigrp/v2.0/companies(bb48a1cd-88b6-ef11-b8eb-6045bdc89e63)/apigrpsalesinvs?$expand=apigrpSalesInvLines HTTP/1.1
Content-Type: application/json
Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxx
User-Agent: PostmanRuntime/7.43.4
Accept: */*
Host: bcserver3-default:7048
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 465
{
"no": "INV002",
"sellToCustomerNo": "10000",
"postingDate": "2025-11-16",
"apigrp": [
{
"lineNo": 1,
"type": "Item",
"no": "1896-S",
"description": "test 1",
"quantity": 1,
"unitPrice": 100
},
{
"lineNo": 2,
"type": "Item",
"no": "2000-S",
"description": "test 2",
"quantity": 1,
"unitPrice": 200
}
]
}
HTTP/1.1 201 Created
Cache-Control: no-cache, no-store
Transfer-Encoding: chunked
Content-Type: application/json; odata.metadata=minimal; odata.streaming=true
Content-Encoding: br
Location: http://bcserver3-default:7048/BC/api/apipub/apigrp/v2.0/companies(bb48a1cd-88b6-ef11-b8eb-6045bdc89e63)/apigrpSalesInvs('INV002')
Vary: Accept-Encoding
Server: Microsoft-HTTPAPI/2.0
urls-rewritten-to-public: false
OData-Version: 4.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: Date, Content-Length, Server, OData-Version
request-id: 75c96f3a-1507-486b-bf1c-44e38ca729d2
Date: Thu, 08 May 2025 02:11:58 GMT
{"@odata.context":"http://bcserver3-default:7048/BC/api/apipub/apigrp/v2.0/$metadata#companies(bb48a1cd-88b6-ef11-b8eb-6045bdc89e63)/apigrpSalesInvs/$entity","@odata.etag":"W/\"JzIwOzE3NTU0ODQ4MjIzODc5MzIwNTA2MTswMDsn\"","no":"INV002","sellToCustomerNo":"10000","postingDate":"2025-11-16","apigrpSalesInvLines":[]}
0
Answers
-
Wat is 'not working'? What sort of response do you get?0
-
What is error please?United Kingdom0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
