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
- Method
- List of Headers
- Body
So let's get started...
The URL
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 locally:
http://localhost:8080/accountright/
Working in the cloud:
https://api.myob.com/accountright/
The URL that you use is made up of three parts - base URL, the company file GUID and the endpoint. Here is an example:
Method
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.
Either the AccountRight Postman Collection or the AccountRight Endpoint Documentation with be able to give you insight on this.
Headers
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:
Authorization: Bearer[OAuth_access_token]
x-myobapi-key: [Your-API_key]
x-myobapi-version: v2
Accept-Encoding: gzip,deflate
Content-Type: application/json
x-myobapi-cftoken: [Base64Encode(username:password)]
For the desktop API, the Headers are slightly different. Here are the Headers used for the desktop API:
Authorization: Basic[Base64Encode(username:password)]
x-myobapi-key: [Your-API_key]
x-myobapi-version: v2
Content-Type: application/json
or
x-myobapi-cftoken: [Base64Encode(username:password)]
x-myobapi-key: [Your-API_key]
x-myobapi-version: v2
Content-Type: application/json
Body
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.
Comments
0 comments
Article is closed for comments.