Use only one web service to export data of multiple tables - controlled by url parameters

KURNKURN Member Posts: 4
Hi,

as my NAV experience is kinda small I would like to explore the possibilities of the NAV (2016/2018) web services. My last development in NAV was in 2014 (CC09) - just for a few weeks. Now I have been dragged into a NAV project and have to care about the communication through web services.

The idea:

We would like to export some data (e. a. Customer, Item) through one published web service. Of course we could publish multiple web services for every need, but the goal is to publish just one service and control it via parameters.

example web service url with parameters (could be a query or a page?):

http://SERVER:PORT/NAVTIER/OData/Company('COMPANY')/ExportService?$filter=exportTable eq 'Customer'
http://SERVER:PORT/NAVTIER/OData/Company('COMPANY')/ExportService?$filter=exportTable eq 'Item'

If a request is made to this url - the web service should response the Customer or Item data - preferable in the normal oData output format with columns and values. In future we would also like to pass other parameters to the service for more detailed filtering or pagination. The service will be read only always and is only used for exports. We would like to avoid to create csv files or go down to raw sql to retrieve all needed data.

Has anyone had experience with this approach? Is it possible at all or have the output structure (columns) of the web service pre defined always?
If this idea is not good at all, any other advice about handling exports without creating multiple web services would be amazing too.

Best regards
Kurn


Answers

  • You can have multiple functions in one WS. Just publish codeunit with multiple functions.
    Or if you insist to have ony function, than use a function parameter to control what to return.
Sign In or Register to comment.