More examples

Get installed payment methods

    GET http://localhost:1260/api/v1/Payments/Methods?$filter=Installed eq true

Note that payment methods in SmartStore.Net are plugins and not entities, so we must use the `/api/v1/` service here.

Get return requests for customer with ID 1

     GET http://localhost:1260/odata/v1/Customers(1)/ReturnRequests?$top=25&$inlinecount=allpages

Note the inlinecount option which tells OData to return an odata.count value with total count of matching entities in the response.

Mark order with ID 145 as payed

    POST http://localhost:1260/odata/v1/Orders(145)/PaymentPaid

This request is called OData action because it is initiating further data processing on the server.
Note the second line which are optional OData action parameters. They are send in the request body, not in the query string. This example additionally set the system name of the payment method to `Payments.Sofortueberweisung` with which order 145 was balanced.

Other actions that would change the payment status are `PaymentPending` and `PaymentRefund`. `PaymentRefund` supports the action parameter `Online`. True would call the related payment gateway to refund the payment. Use the action `Cancel` to cancel an order.

Get shipping address for order 145

    GET http://localhost:1260/odata/v1/Orders(145)/ShippingAddress

This request is called OData navigation. Use `BillingAddress` if you want the billing address of an order to be returned.

Partially update address with ID 1

    PATCH http://localhost:1260/odata/v1/Addresses(1)?SmNetFulfillCountry=US&SmNetFulfillStateProvince=NY
    {"City":"New York","Address1":"21 West 52nd Street","ZipPostalCode":"10021","FirstName":"John","LastName":"Doe"}

The example uses SmNetFulfillCountry and SmNetFulfillStateProvince options to update the country (USA) and province (New York). That avoids extra querying of country and province records and passing its IDs in the request body.
Note that you cannot use a path `/Orders(145)/ShippingAddress` to update an address because `ShippingAddress` is a navigation property and updates are not supported here.

Get email address of customer with ID 1

    GET http://localhost:1260/odata/v1/Customers(1)/Email

Get ID of store with name my nice store

    GET http://localhost:1260/odata/v1/Stores?$top=1&$filter=Name eq 'my nice store'&$select=Id

Note the select option which tells OData just to return the Id property.

Getting localized property values

    GET http://localhost:1260/odata/v1/LocalizedPropertys?$top=120&$filter=LocaleKeyGroup eq 'Product' and EntityId eq 224 and Language/LanguageCulture eq 'en-US'

That's where OData filter enter the equation. That request filters all english property values for a product with the ID 224. LocaleKeyGroup is typically the entity name (Product, Category, Manufacturer, ProductBundleItem, DeliveryTime etc.). The result looks like

      "EntityId":224,"LanguageId":1,"LocaleKeyGroup":"Product","LocaleKey":"Name","LocaleValue":"My name for the product","Id":111
     "EntityId":224,"LanguageId":1,"LocaleKeyGroup":"Product","LocaleKey":"FullDescription","LocaleValue":"<p>Hello world! My product description goes here...</p>","Id":113

LocaleKey is the context property name (here name and full description of the product entity). LocaleValue offers the localized value.

Last edited Jul 25, 2014 at 1:38 PM by mgesing, version 7