Using functions in Odata Webservices

AitorEG
Member Posts: 342
Hi everyone,
I am creating an extension for integrating via REST webServices with an external application.
First of all, I've created a simple table:
The result is not bad, I get the record with 33888 key, and the 'nombre' field is changed to 'clip'.
BUt of course, the goal of this development is to send the new 'nombre' as parameter, not fixed into the code.
How can be this made? I'm reading about this issue, boundary actions and all that, but I don't understand how to define correctly the objets, and how to make the call to the URL... Probably somethin with the actioncContext and OdataActionManagement, but I'm lost.
Any hint will be really appreciated
I am creating an extension for integrating via REST webServices with an external application.
First of all, I've created a simple table:
fields { table 50701 "KanbanizeCard" ..... field(1; "ID"; Integer) { Caption = 'ID'; DataClassification = ToBeClassified; } field(2; "Nombre"; Text[200]) { Caption = 'Nombre'; DataClassification = ToBeClassified; } }I've published a page for this table as a WebService, and created this function:
} [ServiceEnabled] procedure AddCard(var actionContext: WebServiceActionContext) var card: Record KanbanizeCard; ODataActionManagement: Codeunit "OData Action Management"; begin ODataActionManagement.AddKey(Rec.FieldNo(ID), Rec.Nombre); card.Get(Rec.ID); card.Nombre := 'clip'; card.Modify(); end;And I'm calling with post, to this URL:
https://api.businesscentral.dynamics.com/v2.0/xxxxxx-e780-4167-8bff-xxxxxx/SandboxKANBANIZE/ODataV4/Company('CRONUS ES')/KanbanCard(33888)/NAV.AddCard()
The result is not bad, I get the record with 33888 key, and the 'nombre' field is changed to 'clip'.
BUt of course, the goal of this development is to send the new 'nombre' as parameter, not fixed into the code.
How can be this made? I'm reading about this issue, boundary actions and all that, but I don't understand how to define correctly the objets, and how to make the call to the URL... Probably somethin with the actioncContext and OdataActionManagement, but I'm lost.
Any hint will be really appreciated
0
Answers
-
Publishing a page will result in consuming odata.
Read about the possibilities for passing filters here.
https://docs.microsoft.com/en-us/odata/concepts/queryoptions-usage
'Misusing' a filter value can give you the possibility to pass 'clip' as a variable.
But normally you would use soap or API services for manipulating data, and odata for
just querying it.0 -
Don't remember exactly but if you put in $filter in your URL and filter on 'clip' using the odata standard you can get the filtervalue OnFindRecord trigger of your page.
Put the filter in a text variable using getfilter on your dataitem.
Reset all filters, and execute your own logic with the text string.0 -
The issue more than filtering, is that I need to pass as parameter foe exameple, a text, to modify the record into database.
Filtering issue seems to be solved. The thing is to send a text for modifying the record. And not just a text, probably in a near future must receive a jSon, and process it.0 -
I understood you perfectly, I faced the same problem. But solved it by adding fields and filters just for the purpose of sending variables. It's a very creative solution, I'd better not recommend it.
0 -
Thanks for your tips TallyHo.
Glad to ear that you solved this issue, I understand what you say about not recommending it, it should be better SOAP...
Ypu solved it sending the fields and filters by URL??0 -
Yes solved it sending the fields and filters URL.
added fields to the table just for the purpose.
Misused getfilter to get my parameters/data. Resetted all filters after the call, and
continued my own way through c/al coding.
But it whas to create a link with a call log for ip phone server.
Nothing shocking.0 -
And how was the URL looking? I understand that you weren't using boundary actions,. am I right?0
-
$filter='Phone No.' IS %phone%"
This is what was added to the url0 -
Thanks TallyHo, I'll work on it!0
-
Hi @TallyHo,
When you pass that paremeter from a IRL, you are using directly the oData URL of a page, or you are refering to a boundary action, and calling it as a funtion, like for exameple, tthis:
https://api.businesscentral.dynamics.com/v2.0/xxxxx-e780-4167-8bff-xxxxxx/SandboxKANBANIZE/ODataV4/Company('CRONUS ES')/KanbanCard(33888)/NAV.AddCard()
How do you get or process those parameters into the page?
Sorry for all this question, but I'm trying to integrate with a 3rd partner software, and using REST is mandatory,,,,0 -
Not using ODataV4, and using queries this is the way I went about it:
http://localhost:9323/BC150/OData/Company('CRONUS Nederland BV')/Cust
http://localhost:9323/BC150/OData/Company('CRONUS Nederland BV')/Cust?$filter=Item_No eq '1968-S'
0 -
Try publishing your page in the webservices section, and use the url suggested there0
-
Interesting.. So using "normal" Odata.
With that URL you are "atacking" customer pageno? What is the goal of that URL? And in the page how did you proceess the parameters?0 -
No this was a NAV query object published in webservices. Easier to use odata query language on that. But it has to be possible to achieve the same with a published page, odata is odata. But looking into a published page I can see your trouble now. The results are all messed with links and bookmarks.
The way I went about for the phone link was calling the page through a direct call to the webclient created a page especially for the purpose (forgot about that, sorry). This way I could enter the filters the same way I did it in my example of the published query Cust. So Odata querying works for direct calls to a specific page in the web client too.
0 -
Thanks for your tips,really appreciated.
This week I will have a development meeting with the externela application developer, we'll see if we can achieve something interesting...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