API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

REST API parameters

0
How do I use query parameters?

The following example returns all customers instead of the one asked for:

https://restapi.e-conomic.com/customers?email=bill.gates@microsoft.com
created Oct 13, 2014 by pederb
25% Accept Rate
Q 4 A 2 C 1

2 Answers

+1
 
Best answer

Short answer: https://restapi.e-conomic.com/customers?filter=email$eq:bill.gates@microsoft.com

 

If you set https://restapi.e-conomic.com/customers?filter=randomvalue, you force a response detailing how and what to filter. The options vary depending on the endpoint, and some seem not to be implemented yet.

 

Copy-paste of a response:

{
    "allowedFilteringFields": [
        "zip",
        "customerNumber",
        "name",
        "balance",
        "address",
        "ciNumber",
        "city",
        "country",
        "county",
        "creditLimit",
        "ean",
        "email",
        "publicEntryNumber",
        "telephoneAndFaxNumber",
        "vatNumber",
        "website",
        "barred"
    ],
    "allowedFilteringOperators": {
        "Equals": "$eq:",
        "Not equals": "$ne:",
        "Greater than": "$gt:",
        "Greater than or equal": "$gte:",
        "Less than": "$lt:",
        "Less than or equal": "$lte:",
        "Substring match": "$like:",
        "And also": "$and:",
        "Or else": "$or:"
    },
    "escapeCharacters": {
        "$": "$$",
        "(": "$(",
        ")": "$)",
        "*": "$*"
    },
    "wildcard": "*",
    "nullValue": "$null:",
    "message": "Could not parse query string filter.",
    "developerHint": "Filtering on collections can be done using the querystring parameter 'filter'. Use the allowed operators and allowed filtering fields to create your query. To enforce operator affinity you can group expressions using parentheses. The $like: filter supports both using wildcards (*) and not using wildcards. If no wildcards are used, the expression is considered a 'contains' expression and effectively becomes a filter with a wildcard at the start of the string and one at the end of the string. Example: filter=name$eq:Joe$and:city$like:*port",
    "logId": "e470dc58-8f02-41a2-8d24-194f1adcabf6",
    "httpStatusCode": 400,
    "errors": [
        "Syntax error, expected: $eq:, $lt:, $lte:, $gt:, $gte:, $ne:, $like:"
    ]
}
answered Oct 14, 2014 by jbk
selected Oct 15, 2014 by mortenanders
+1

You can also do sorting.

This sorts ascending by email. 

https://restapi.e-conomic.com/customers?sort=email

If you wish sort descending by email then prefix with a - (minus)

https://restapi.e-conomic.com/customers?sort=-email

If you wish sort by multiple properties then, just separate them with a comma

https://restapi.e-conomic.com/customers?sort=zip,-name

If you wish force sorting alphabetically prefix with a ~ (tilde). If you try to sort by something jibberish, then you will get this message:

{
  "allowedSortingFields": [
    "zip",
    "customerNumber",
    "name",
    "balance",
    "address",
    "ciNumber",
    "city",
    "country",
    "county",
    "creditLimit",
    "ean",
    "email",
    "publicEntryNumber",
    "telephoneAndFaxNumber",
    "vatNumber",
    "website"
  ],
  "allowedSortingOperators": {
    "Sort ascending (default)": "",
    "Sort ascending": "+",
    "Sort ascending, force alphabetical sorting": "~+",
    "Sort descending": "-",
    "Sort descending, force alphabetical sorting": "~-"
  },
  "message": "Could not parse query string sort parameter.",
  "developerHint": "Sorting on collection endpoints is done by appending a querystring parameter sort to the collection url. Define sort order by using any of the supported operators to prefix the property name with. Sorting by multiple fields is done by separating the field names by comma. An example is sorting ascending by name and then descending by balance: ?sort=name,-balance",
  "logId": "31569cc0-6eb7-45a5-9bf3-929e0ed21e9e",
  "httpStatusCode": 400,
  "errors": [
    "Sorting is not allowed on property 'abc'."
  ]
}

 

 

 

answered Oct 14, 2014 by rbb

Network

Find all the documentation and resources you need to build great apps.
Go to Developer site

Newsletter

Get the latest news and important info from the e-conomic developer world.
Sign up now

Visma e-conomic A/S
...