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>