OData V4 series of actions and functions, odatav4

Source: Internet
Author: User

OData V4 series of actions and functions, odatav4

OData learning directory

Anyone who knows about webapis knows that the default WebApi methods include Get, Post, and Put. If too many other Post methods are added, they cannot be identified, and other preparations need to be added, the requested Url must contain the Controller and Action, which is inconsistent with the Restful design. Odata can solve this problem.

Configure routing Service

Builder. namespace = "ProductService"; builder. entityType <Product> (). collection. function ("MostExpensive") // Function routing. returns <double> (); builder. namespace = "ProductService"; builder. entityType <Product> (). action ("Rate") // Action route. parameter <int> ("Rating ");

When MostExpensive is requested through Get, the following error occurs:

Modify Web. config <modules runAllManagedModulesForAllRequests = "true"> </modules>

Action Request

              $.ajax({                url: "/Odata/Products(" + id + ")/ProductService.Rate",                type: "POST",                contentType: "application/json; charset=utf-8",                dataType: "JSON",                data: JSON.stringify({ Rating: 5 }),                success: function (r) {                    debugger;                },                error: function (e) {                    debugger;                }            });

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.