• Getting Started
    • Prerequisites
    • Download and Installation
    • Change Log
  • Developer Guide
    • EvenCart Plugins
      • Development Environment Setup
      • Plugin Structure
      • EvenCart MVC
      • Dependency Injection
      • Domain Entities
      • Database Versions
      • Plugin Settings
      • Data Provider Plugin
      • Payment Processing Plugin
      • Shipping Provider Plugin
      • Authentication Provider
      • Widget Plugin
    • EvenCart API
      • Authentication
      • Requests & Responses
      • API EndPoints
    • Caching
  • Designer Guide
    • How to create a theme
    • Extended Tags
      • Layout Tag
      • Widget Tag
      • Json Tag
      • Css Tag
      • Js Tag
      • Bundle Tag
      • Partial Tag
      • Control Tag
      • Route Tag
      • Global Tag
      • Component Tag
    • Extended Filters
    • Global Objects
  • Packaging & Distribution

Requests & Responses

As mentioned on API Authentication page, all the requests must have some form of header to fulfill a request. The following document explains the request and response formats used by EvenCart API.

Request Format

EvenCart has specific requirements for sending requests to the app. The requests must conform to these rules for API calls to work correctly.

  1. For POSTs requests, the Content-Type header must be set to application/x-www-form-urlencoded.
  2. For GET requests, the parameters should be sent as query string parameters appended to the endpoint URLs.
  3. The method should only be GET and POST. No other methods are support. For CORS, OPTIONS method is supported.
  4. For end points which don't require authentication, the header X-API-VERIFICATION must be sent with each request. The header is not required in case the user's bearer token is being sent.

Response Format

All the responses in the EvenCart API are JSON with response content type set to application/json. All the responses follow a common JSON structure.

{
    "success": true,
    "context":"name of context",
    "error": "only if success is false"
    ...
}

As seen from the example above, all the responses will include a success key set to either true or false.

The value indicates if the request succeeded or not. A context key in the response indicates the context name for the request. An optional error key is included in the response, in case success is false.

Note: You should not rely solely on success value to check if the request was successful or not. Always rely on HTTP Status code in addition to make sure that request was successful. A 200 response code will ensure that the request was successful. Note however that success may be false for a 200 response, thus you should read the error key to know the reason for failure.

In addition to the above mentioned keys, each response may contain additional keys depending on the endpoint.

Next Steps

Congratulations! Now that you've understood about the API authentication and usage, you can start consuming the API endpoints and create some awesome apps.

ON THIS PAGE
  • Request Format
  • Response Format
  • Next Steps
© 2022 Sojatia Infocrafts Pvt. Ltd. All rights reserved. Powered by onlyDoc.