Skip to content
Developerhome

apiPost

  Less than to read

Summary

The apiPost method is used to create a new item in the backend API using the data from the Redux store. It allows you to send a POST request to the specified API endpoint, typically for creating a new record.

Before using the apiPost method, it is important to ensure that you have retrieved the necessary metadata using the apiGetMetadata method. The metadata provides information about the data types and structure required for the API request.

The apiPost method utilises the unpacked data from the Redux store with the specified prefix. It sends the data as the request payload to the backend API, creating a new item based on the provided data.

After successful execution of the apiPost method, a new item will be created in the backend API based on the data provided in the Redux store. Although the apiPost returns a response body the schema interpreter doesn’t do anything with it, for times when you need to do something with the post response you will need to do an additional GET request.

apiPost Parameters

Parameters Description
endpoint The URL for Sage 200 API endpoint that you require (e.g. v1/departments or v1/customers)
prefix (Optional) A prefix to separate the data in the Redux store.

apiPost Example

"apiPost": {
  "apiPost": {
    "endpoint": "v1/departments",
    "prefix": ""
  }
}