This API is used for uploading a new batch to a watch folder for a given batch class. It executes the new batch with supplied tif, tiff or pdf files. User need to be authorized to execute a batch for a particular batch class otherwise an error message would be generated. All the files would be copied to the unc folder of the requested batch class with the folder name supplied by the user as input.

Request Method POST

Web Service URL: http://{serverName}:{port}/dcma/rest/uploadBatch/{batchClassIdentifier}/{batchInstanceName}

Input: A valid tif/tiff file.

 

 

Input Parameter Values Descriptions
batchClassIdentifier A valid batch class identifier Example BC1 The identifier of the batch class in which user wishes to upload its batch.
batchInstanceName Name of the batch which is to be uploaded This name with which user wishes to upload the batch.

 

CheckList:-

  1. The value for batchClassIdentifier is compulsory and should be valid with permissions to the user to run the batch on it.
  2. The value for batchInstanceName is mandatory and if left empty then it will send an error.

Sample client code using apache commons http client:-

private static void uploadBatch() {
		HttpClient client = new HttpClient();
		String url = "http://localhost:8080/dcma/rest/uploadBatch/BC4/US_Invoice_sample";
		PostMethod mPost = new PostMethod(url);
		// adding image file for processing
		File file1 = new File("C:\\sample\\US-Invoice.tif");
		Part[] parts = new Part[1];
		try {
			parts[0] = new FilePart(file1.getName(), file1);
			MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
			mPost.setRequestEntity(entity);
			int statusCode = client.executeMethod(mPost);
			String responseBody = mPost.getResponseBodyAsString();
			// Generating result as responseBody.
			System.out.println(statusCode + "***" + responseBody);
			if (statusCode == 200) {
				System.out.println("Web service executed successfully.");
			} else if (statusCode == 403) {
				System.out.println("Invalid username/password.");
			} else {
				System.out.println(mPost.getResponseBodyAsString());
			}
		} catch (FileNotFoundException e) {
			System.err.println("File not found for processing.");
		} catch (HttpException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (mPost != null) {
				mPost.releaseConnection();
			}
		}
	}

Was this article helpful to you?

Engineering

Comments are closed.