Submit a Job

Now that our job is created, all that's left is to submit it! This is done with a POST call to the /jobs/{id}/submit enpoint, using the ID returned from the /jobs call that created the job.

The one required parameter is billingType, which we will set to 'User Credit' for this tutorial so that we can use the credit we added previously.

The following code sample demonstrates submitting a job.

# Load the HTTP requests module
import requests

# Note the ID of the previously-created job
jobId = '8675309'

# Define the endpoint to use, including the jobId
url = "https://stage-rest.click2mail.com/molpro/jobs/" + jobId + "/submit"

# Define credentials
myusername = 'awesomeuser'
mypassword = 'gReAt/PaSsWoRd123'

headers = {'user-agent': 'my-app/0.0.1'}

# Set the source of payment for the job
values = {'billingType': 'User Credit'}

# 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)

HTTP Return Codes And Possible Statuses

HTTP Response 200

Status

Description

0

Success

1

Job ID not found

2

User does not have access to this payment method

2

payment not authorized

HTTP Response 400

Status

Description

9

One of the required parameters is missing.

9

Job with Id is in impermissible state

9

Not authenticated

9

Only Credit Card, Invoice, ACH, User Credit, Apple Pay, Google Pay are allowed.

9

Shipping method information required

9

custom error message related to job submission

HTTP Response 500. If you get a 500 response please contact Click2Mail customer support.