ODATA - Adding header and lines in one call/round trip

HeidiAlford
Member Posts: 4
Hi 
Hopefully someone here can help me with this, I'm finding useful documentation and examples for ODATA in Business Central hard to come by.
I have custom tables ("Inbound Job" and "Inbound Job Task Line"), the usual page (InboundJobQuotes) and subform (serviceLines) setup for ODATA web services. Using Postman I can create a header as follows:
Anyone know what I'm doing wrong?
TIA

Hopefully someone here can help me with this, I'm finding useful documentation and examples for ODATA in Business Central hard to come by.
I have custom tables ("Inbound Job" and "Inbound Job Task Line"), the usual page (InboundJobQuotes) and subform (serviceLines) setup for ODATA web services. Using Postman I can create a header as follows:
POST [..] InboundJobQuotes { "jobno":"JO001", }..and a subform line as follows:
POST [..] InboundJobQuotesserviceLines { "jobno": "JO001", "lineno": 1, "description":, "Description JO001" }But that's two round trips. Ideally (And surely it should support this) I want this:
POST [..] InboundJobQuotes { "jobno":"JO001", InboundJobQuotesserviceLines: [ { "lineno": 1, "description":, "Description JO001" } ] }I get no error, but no lines are created either.
Anyone know what I'm doing wrong?
TIA
0
Best Answer
-
I am glad they are not letting you use SOAP hehe
So in NAV, ODATA and API are different endpoints.
See https://docs.microsoft.com/en-us/dynamics-nav/api-reference/v1.0/endpoints-apis-for-dynamics
API does not use the webservice table to be configured.
Batch requests are not supported afaik.
5
Answers
-
This works with the API endpoint, not the ODATA endpoint.
This is called a 'deep insert'
for example: https://forum.mibuso.com/discussion/72423/api-deep-insert-not-working-in-custom-entity0 -
I did wonder if this was down to my misunderstanding of how the API works. I've been using SOAP services in NAV for years but how the API is setup is confusing me.
My main API page has an EntitySetName of 'jobQuotes', the subform has an EntitySetName of 'serviceLines':part(serviceLines; "Inb. Service Line Entity") { EntitySetName = 'serviceLines'; EntityName = 'serviceLine'; SubPageLink = "Job Id" = field(SystemId); }
I added it to the Web Service table as per usual as InboundJobQuotes, I'm not sure if that's the right way to reference the API /shrug
When I call it from Postman I use the usual endpoint (As specified in Web Services), when I do the deep insert it insists I call it InboundJobQuotesserviceLines rather than serviceLines.
EG.POST [..] InboundJobQuotes { "jobno":"JO001", InboundJobQuotesserviceLines: [ { "lineno": 1, "description":, "Description JO001" } ] }
When I was expecting...POST [..] InboundJobQuotes { "jobno":"JO001", serviceLines: [ { "lineno": 1, "description":, "Description JO001" } ] }
Postman will complain about untyped values if I use serviceLine.
I know I'm doing something wrong based upon my misunderstanding of how this works. I wish they'd let me use SOAP lol.
Bonus question: Can we use batch requests with ODATA?
Thanks
H0 -
I am glad they are not letting you use SOAP hehe
So in NAV, ODATA and API are different endpoints.
See https://docs.microsoft.com/en-us/dynamics-nav/api-reference/v1.0/endpoints-apis-for-dynamics
API does not use the webservice table to be configured.
Batch requests are not supported afaik.
5 -
Correction, batching should be supported as mentioned on https://docs.microsoft.com/en-us/dynamics-nav/api-reference/v1.0/dynamics-rate-limits
(I have never tried it myself)0 -
@foo_bar Thanks
As it turns out this has been a complete misunderstanding of how I access the API. Don't bother putting it in the web services table, most importantly use the right endpoint.
It makes so much more sense now lol.
Thanks again!0
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
- 320 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