Skip to main content

Notifications

Announcements

No record found.

Business Central forum

ODATA action bound parametrs issue

Posted on by 20

Hi Colleagues,


I am working on integration Business central (SAAS) with electronic document service. For get result from external web service we should create webhook webservice in BC. It should be REST web service with authorization in url.
I created page with [ServiceEnabled] function

[ServiceEnabled]
procedure webhook(RequestId: Text; resultId: Text; pages: integer; result: Integer; status: integer; ubl: Text; warnings: Text; errors: Text) Outparam: Text //

begin
Outparam := '1';


end;


call it via Postman

POST /v1.0/77cdf104-76fa-***e1-0746729fcb0f/Sandbox/ODataV4/Company('CRONUS%20NL')/IntegrationPage('CRONUS%20NL')/NAV.webhook? HTTP/1.1
Host: UserID:serviceToken@api.businesscentral.dynamics.com
Content-Type: application/json
cache-control: no-cache
Postman-Token: 7a311a4e-f652-4238-ab91-2fdb0c3acaab
{"requestId":"3e8d58e6-be97-4c8c-b7de-049c2c18932c","resultid":"65319245-b591-471b-84f7-008d492ef5a5","pages":1,"result":16,"status":15,"ubl":"base64string","warnings":"No detailline(s) discovered, substituting totals instead","errors":"No Customer/Supplier detected"}



and received the response

{
"@odata.context": "api.businesscentral.dynamics.com/.../77cdf104-76fa-***1-0746729fcb0f/Sandbox/ODataV4/$metadata#Edm.String",
"value": "1"
}



but in fact external service send we request with params beginning with capital letter {"RequestId": instead of {"requestId"
if I change first letter then I received this error in response

{
"error": {
"code": "BadRequest",
"message": "Exception of type 'Microsoft.Dynamics.Nav.Service.OData.NavODataBadRequestException' was thrown."
}
}



Have you any idea how setup the odata parameters beginning with capital letter?

Next problem is JSON array that comes from external web service in parameter "warnings". It look like this: ,"Warnings":["No detailline(s) discovered, substituting totals instead"]. I tried to set any type (JsonArray,JsonObgect Array[100] of Text )for this param in function webhook but nothing helps. I think that types are not supported types of ODATA, because if I set them the service is disappeared from /ODataV4/$metadata

if I set type Text and in request set brackets [ ] a get the same error in response (Exception of type )
Any idea how solve it?
ODATA Action metadata:

<Action Name="webhook" IsBound="true">
<Parameter Name="bindingParameter" Type="NAV. IntegrationPage" />
<Parameter Name="requestId" Type="Edm.String" />
<Parameter Name="resultid" Type="Edm.String" />
<Parameter Name="pages" Type="Edm.Int32" />
<Parameter Name="result" Type="Edm.Int32" />
<Parameter Name="status" Type="Edm.Int32" />
<Parameter Name="ubl" Type="Edm.String" />
<Parameter Name="warnings" Type="Edm.String" />
<Parameter Name="errors" Type="Edm.String" />
<ReturnType Type="Edm.String" />
</Action>


Categories:
  • Ssenyonjo Profile Picture
    Ssenyonjo 5 on at
    RE: ODATA action bound parametrs issue

    Very true, the request body must have its keys begin with small letters. { lineNo: 11} and NOT { LineNo: 11}.

    Take a look at page 5475 “Sales Invoice Entity” for details on how to use Bound Actions. Also you can achieve the same thing without the ActionContext fuss. Take a look at this guide: docs.microsoft.com/.../walkthrough-creating-and-interacting-odata-v4-bound-action VERY IMPORTANT: Make sure when you are sending the request, the request body json keys start with a small letter. To make it easy to remember ensure that your parameter names in the NAV function begin with a small letter. For example: employeeNo instead of EmployeeNo. If you send a request json body with the key beginning a capital letter you will get an error saying: BadRequest: Exception of type ‘Microsoft.Dynamics.Nav.Service.OData.NavODataBadRequestException’ was thrown. CorrelationId: 6ca2a4e1-8e37-4c6b-b542-6813bcf61d74. So don’t use: { LineNo: 30 }, use { lineNo: 30 } as your request body.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans