Create batch configuration

Last update: 2024-01-25
  • Created for:
  • Beginner
    Intermediate
    Developer

To use a batch API, create a batch configuration and execute a run based on that configuration. The following video shows a demonstration of creating batch configuration using the API

NOTE

Please make sure the AEM user belongs to

forms-users
group to make API calls.

 Transcript

Now that we have created all the necessary configurations, the next step is to invoke the batch APIs. For the purpose of this video, I’m going to use Postman to make those API calls, but in real life you’ll be using a programming language of your choice to make those API calls. To start using Postman, first thing we need to do is to get the access token and to get the access token, I’ve logged into my Cloud Manager Instance and I’m going to go into the Developer Console here and click on the Integrations tab. And I’m going to get the Local Development Token. Again, this is only for development purposes or for testing purposes. So click here and you will get this access token. So copy this access token. We’ll be using it later to make those API calls. So, I’m going to copy this access token. And the first API call that we are going to make will create the configuration here. So the first API call is going to create the configuration and the endpoint for creating the configuration is this. This is your instance name. And then this is the endpoint here, config and it requires the following parameters as a request parameter.

It’s a configuration name. The data source configuration URI. So this is the configuration URI that we created earlier. Output Types PDF and then the template. So this is the location of your xdp template in your forms, Cloud Service Instance. In my case, it is residing under content dam forms and documents form templates custom fonts. .xdp is the name of the template. So let’s copy this configuration. Let’s copy this parameter here.

Copy this and open up my Postman here. And I’ve copied the URL here. It’s a post call. So that’s the URL that will create the configuration. And in the headers, I’ve already specified the authorization key here. That’s the authorization. And then the Bearer followed by the access token that we got a little earlier. And then in the body here, you can simply copy and paste the configuration here. So, done. Paste. So here is the configuration name is monthly statements and these are the other parameters. And then that’s the template names. So now if you do a send, you get a 201 indicating that that particular configuration was successfully created. Once you have created the batch configuration, you can verify the successful creation of the batch configuration by making a simple GET call to this URL followed by the batch configuration name that we had used in the earlier API call. So the monthly statements was the name of the batch configuration. And if you were to make this call, a GET call, you would get back the details about that batch configuration here. The configuration name, data source, output types and the template. So now our batch configuration is created. We are now ready to execute against that particular batch configuration. -

Create Batch Configuration

The following is the POST endpoint for creating Batch config

<baseURL>/config

The following is the minimum configuration that needs to be specified when creating batch configuration. This needs to be passed as JSON object in the body of the HTTP request

{
	"configName": "monthlystatements",
	"dataSourceConfigUri": "/conf/batchapi/settings/forms/usc/batch/batchapitutorial",
	"outputTypes": [
		"PDF"
	],
	"template": "crx:///content/dam/formsanddocuments/formtemplates/custom_fonts.xdp"

}

Verify Batch configuration

To verify the successful creation of batch configuration, you can make a GET request call to the following endpoint

<baseURL>/config/monthlystatements

You only need to pass an empty JSON object in the body of the HTTP request

On this page