Hi All,
I need to create a webservice in NAV 2018 to be used in an external app. The webservice is called for a specific item number, the webservice should return a JSON with some relevant information of this specific item.
I have a hard time finding a good example which is covering this issue, can anybody provide me a simple example?
Thanks in advance,
Yannick
0
Answers
https://docs.microsoft.com/en-us/dynamics-nav/how-to--publish-a-web-service
to filter to a specific record, see https://docs.microsoft.com/en-us/dynamics-nav/using-filter-expressions-in-odata-uris
www.pardaan.com
@denpar, why not use a page webservice?
Is it possible to test it in Postman? I tried something like this....
Made this codeunit and published it as a webservice
How can I check if it's working in Postman (correct return value)?
www.pardaan.com
In Postman you need to set up your call in the following way:
You should then see your JSON in the response body below
www.pardaan.com
There is even a Item Entity and it returns JSON
Take a look at this https://community.dynamics.com/business/b/andreysnavblog/posts/how-to-obtain-data-from-nav-standard-apis
The url for the item entity is
{{http}}://{{url}}/{{service}}//API/beta/companies({{companyId}})/items
Then you just use filters to get the items you want
I didn't say I advise it, or that it's the best, last and only solution. I offered it as an alternative and was asked for more details.
www.pardaan.com
Yes you can, that is what the API does very well and easily, you are limited to three levels though, you can return Page, SubPage and then you can also return Complex Types
Good example would be Sales Invoice Entity (Page 5475) and Sales Invoice Line Entity (Page 5476) and The Sales Invoice Line Entity has field LineObjectDetailsJSON which is complex type.
To get the sales invoices and sales invoice lines your url would be something like the following
{{http}}://{{url}}/{{service}}//API/beta/companies({{companyId}})/salesInvoices?$expand=salesInvoiceLines
Here's tutorial I did a while back on complex type, https://forum.mibuso.com/discussion/72539/nav-2018-api-complex-types#latest
www.pardaan.com