So you have made it past OAuth, the next step is to build your request for AccountRight API.
The request is made up of 4 parts
- The URL
- List of Headers
So let's get started...
The first part of a request that you need to supply is a base URL. With the AccountRight API, you will need to decide if you are going to work in the cloud or locally. As this will determine which base URL to use.
Working in the cloud:
The URL that you use is made up of three parts - base URL, the company file GUID and the endpoint. Here is an example:
The Method part of the request determines the action that you want to take with the API. The methods that the AccountRight API supports are;
GET - This will retrieve data
POST - Ths will create new data.
PUT - This will allow you to update existing data
DELETE - This will allow you to remove data.
One thing to note is that not all endpoints will support all Methods. Its recommended that you check out the endpoint documentation to make sure that you are using a supported Method for the endpoint that you want to use.
Headers are an essential part of any request. They carry information that the API needs to accept the request. Each API will have different headers that are required. Here are the ones that AccountRight needs for the cloud API:
For the desktop API, the Headers are slightly different. Here are the Headers used for the desktop API:
Not all API requests will require a Body but depending on the Method that you are using will determine if you need to add a Body to the request.
The POST and PUT Methods are the two methods that most likely will require a Body to be supplied. The Body is where you supply the data that you want to use in your API request.
Check out our Create an Invoice article to explore what the Body of a POST looks like.