Create a Job
Once you have credit in your account, a document uploaded, and an address list created, it's time to create the job that you want to execute. The job process consists of first creating a job and getting its ID, then submitting the job. Job creation is done with a POST to the /jobs endpoint.
Creating a job has 9 required parameters, and a large number of optional parameters that are beyond the scope of this tutorial.
Job Creation Required Parameters
Parameter | Description |
---|---|
documentClass | The general type of the product |
layout | The specific type of the product |
productionTime | The desired production time |
envelope | If this is an enveloped product this determines the envelope in which the product is to be mailed; otherwise provide no value |
color | Print in color or black and white |
paperType | Sets the paper the mailing is to be printed on |
printOption | Sets simplex or duplex printing |
documentId | ID of the document to print |
addressId | ID of the address list for the job |
The following Python code example creates a job using document 12345 and address list 78902 with a typical set of options:
# Load the HTTP requests module
import requests
# Define the endpoint to use
url = "https://stage-rest.click2mail.com/molpro/jobs"
# Define credentials
myusername = 'awesomeuser'
mypassword = 'gReAt/PaSsWoRd123'
headers = {'user-agent': 'my-app/0.0.1'}
# Build the dictionary of parameters to describe the job
values = {'documentClass' : 'Letter 8.5 x 11',
'layout' : 'Address on Separate Page',
'productionTime': 'Next Day',
'envelope' : '#10 Double Window',
'color' : 'Black and White',
'paperType' : 'White 24#',
'printOption' : 'Printing One side',
'documentId' : 12345,
'addressId' : 78902}
# Make the POST call
r = requests.post(url, data=values, headers=headers, auth=(myusername, mypassword))
# Display the result - a success should return status_code 201
print(r.status_code)
# Display the full XML returned.
print(r.text)
A successful call should return an HTTP 201 status and the XML similar to the following:
201
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<job>
<id>13331417</id>
<status>0</status>
<description>Created</description>
<statusUrl>https://stage-rest.click2mail.com/molpro/jobs/13331417</statusUrl>
</job>
HTTP Return Codes And Possible Statuses
HTTP Response 200
Return Code | Description |
---|---|
0 | Created |
1 | DocumentId not found |
1 | Job DocumentId not found |
1 | Job Address list Id not found |
3 | Address List ID not found |
4 | Document Type cannot Mail Internationally |
5 | Project does not exist |
9 | Address list not valid for selected Product |
9 | Quantity required for selected product |
9 | Custom error related to quantity |
HTTP Response 400
Return Code | Description |
---|---|
9 | One of the required parameters is missing. |
9 | Product not authorized for this customer |
9 | Return address Name OR Return address Organization is required for selected product. |
9 | Endorsements not valid for selected product |
9 | Return Address not valid for selected product |
9 | Minimum Quantity for selected product is |
9 | Maximum Quantity for selected product is |
9 | Custom error related to enclosures |
9 | Future date greater than days |
9 | Mailing date should be greater than current date. |
HTTP Response 500
If a 500 error is returned, please contact Click2Mail support.
Return Code | Description |
---|---|
9 | custom error message related to server error |
9 | Could not parse date. Please add mailingDate parameter in form 'yyyymmdd'. |
Updated 9 months ago