Good to know: Mautic has a tool called API tester that allows to test the request you send. Click on this link and go in the directory APItester.
Also, please do not send more than 2 requests per second.
In this article, we will se how to set a request to the Automation API with the authorization protocol Oauth2 and a Rest client to get all contacts from Automation.
First of all you need to get an Access Token in the Rest client.
- Modify fields with your own values (URLs, keys).
- Copy the callback URL given by the Rest client in the field when you got the Oauth2 key.
- Authorize the app by clicking on "Get Access Token".
- After clicking, a pop-up window will be displayed where you must fill with your Automation IDs.
- With this Access Token, you will be able to use it to authenticate to make your requests.
- Then you need to put the right token next to the word "Bearer" in the header before submitting the request. (the access token has been refreshed between both screenshot, this is why it is not the same).
- Be careful, do not forget to put the space between the word "Bearer" and the token.
- If there is an authentication error, you must refresh the token and start again.
Now you must go in Automation to create a new API credentials.
- Connect to your Automation instance and click on the gear on the top right corner.
- Click on API credentials
- Click on "Oauth2".
- Click on "New".
- Fill the name and the callback URL (Redirect URL) that you will find when setting the 0auth2 configuration in the Rest client.
Request must be sent when all is set.
For more information about request, please consult the Mautic developer documentation.