How toWeb Service Developer Guide

Web Service Developer Guide

Sana Commerce 8.1
Your provider

Example of Request in XML and JSON

Below see the example of the request in both formats (XML and JSON), containing different filter criteria applied to several fields of the Product entity:

XML
<ProductListLoadOptions xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <Filter>
    <fields>
      <dictionary>
        <FieldCriteriaItem>
          <Key>Inventory</Key>
          <Value>
            <Field>Inventory</Field>
            <Options>
              <Criterion i:type="BetweenCriterion">
                <HighValue i:type="a:decimal" xmlns="http://schemas.datacontract.org/2004/07/Sana.Filtering" xmlns:a="http://www.w3.org/2001/XMLSchema">300</HighValue>
                <LowValue i:type="a:decimal" xmlns="http://schemas.datacontract.org/2004/07/Sana.Filtering" xmlns:a="http://www.w3.org/2001/XMLSchema">100</LowValue>
              </Criterion>
            </Options>
          </Value>
        </FieldCriteriaItem>
        <FieldCriteriaItem>
          <Key>ModifiedDate</Key>
          <Value>
            <Field>ModifiedDate</Field>
            <Options>
              <Criterion i:type="GreaterCriterion">
                <Value i:type="a:dateTime" xmlns:a="http://www.w3.org/2001/XMLSchema">2012-01-03T13:07:51</Value>
                <StrictGreater>false</StrictGreater>
              </Criterion>
              <Criterion i:type="LessCriterion">
                <Value i:type="a:dateTime" xmlns:a="http://www.w3.org/2001/XMLSchema">2011-01-03T13:07:51</Value>
                <StrictLess>true</StrictLess>
              </Criterion>
            </Options>
          </Value>
        </FieldCriteriaItem>
        <FieldCriteriaItem>
          <Key>Title</Key>
          <Value>
            <Field>Title</Field>
            <Options>
              <Criterion i:type="ContainsCriterion">
                <Value i:type="a:string" xmlns:a="http://www.w3.org/2001/XMLSchema">TV Set</Value>
                <Not>true</Not>
              </Criterion>
            </Options>
          </Value>
        </FieldCriteriaItem>
        <FieldCriteriaItem>
          <Key>Blocked</Key>
          <Value>
            <Field>Blocked</Field>
            <Options>
              <Criterion i:type="EqualCriterion">
                <Value i:type="a:boolean" xmlns:a="http://www.w3.org/2001/XMLSchema">false</Value>
                <Not>false</Not>
              </Criterion>
            </Options>
          </Value>
        </FieldCriteriaItem>
      </dictionary>
    </fields>
  </Filter>
  <PageIndex>0</PageIndex>
  <PageSize>10</PageSize>
  <SortAscending>true</SortAscending>
  <SortField>Id</SortField>
  <LoadCalculatedFields>true</LoadCalculatedFields>
  <LoadRelatedProducts>false</LoadRelatedProducts>
  <LoadRelatedSkus>false</LoadRelatedSkus>
  <MultiCurrency>false</MultiCurrency>
  <VisibleOnly>false</VisibleOnly>
</ProductListLoadOptions>
JSON
{
    "Filter":
    {
        "fields":
        {
            "dictionary":
            [{
                "Key":"Inventory",
                "Value":
                {
                    "Field":"Inventory",
                    "Options":
                    [{
                        "__type":"BetweenCriterion",
                        "HighValue":300,
                        "LowValue":100
                    }]
                }
            },
            {
                "Key":"ModifiedDate",
                "Value":
                {
                    "Field":"ModifiedDate",
                    "Options":
                    [{
                        "__type":"GreaterDateTimeCriterion",
                        "Value":"\/Date(1325596071000)\/",
                        "StrictGreater":false
                    },
                    {
                        "__type":"LessDateTimeCriterion",
                        "Value":"\/Date(1357218471000)\/",
                        "StrictLess":true
                    }]
                }
            },
            {
                "Key":"Title",
                "Value":
                {
                    "Field":"Title",
                    "Options":
                    [{
                        "__type":"ContainsCriterion",
                        "Value":"TV Set",
                        "Not":true
                    }]
                }
            },
            {
                "Key":"Blocked",
                "Value":
                {
                    "Field":"Blocked",
                    "Options":
                    [{
                        "__type":"EqualCriterion",
                        "Value":false,
                        "Not":false
                    }]
                }
            }]
        }
    },
    "PageIndex":0,
    "PageSize":10,
    "SortAscending":true,
    "SortField":"Id",
    "LoadCalculatedFields":true,
    "LoadRelatedProducts":false,
    "LoadRelatedSkus":false,
    "MultiCurrency":false,
    "VisibleOnly":false
}

The example in the table above will return the list of products that match the following conditions:

  • The Inventory is between 100 and 300;
  • And the ModifiedDate is greater or equal to '2012-01-03T13:07:51' or is strictly less than '2011-01-03T13:07:51';
  • And the Title does not contain 'TV Set';
  • And the Blocked field is 'false'.
How toWeb Service Developer Guide