API Call to Matillion job issue from Python shell

Hi,

I am trying to run Matillion job from python script using requests.put method, i am getting HTTP 405 Method Not Allowed error, while requests.get method has no issues from python shell. I am able to do requests.put method from cmd prompt without any issues using curl. Please let me know

 

Below is the command I am running

 

headers=headers = {

'Content-Type': 'application/json',

}

 

requests.post(‘http://<instance_address>/rest/v1/group/name/<group_name>/project/name/<project_name>/version/name/<version_name>/job/name/<orchestration_job_name>/run?environmentName=<environment_name>’, headers=headers, verify=False,auth=(‘<api_user>’, ‘<api_user_password>’))

As customer it is tricky to debug code of other customers.

I was playing around a bit with the different possibilities to start and monitor Matillion jobs.

I built an prototype to start and monitor jobs using AWS Step Functions.

Let me share the part used in lambda to actually start a job:

 

To get the request package running you have to include the package inside the uploaded zip. So you can remove the "from package" part.

The part "event['jobname']" can be replaced using the plain job name. I needed this to use parameters calling the actual lambda function.

Enter username/password and the ip address and this solution is working for me inside AWS and locally from my notebook.

 

 

from package import requests

import json

def lambda_handler(event, context):

 group = 'Development'

 project = 'Testing'

 version = 'default'

 job = event['jobname']

 environment = 'Testing'

 user = 'user name' 

 password = 'user password'

 url = 'http://xxx.xxx.xxx.xxx/rest/v1/group/name/'+str(group)+'/project/name/'+str(project)+'/version/name/'+str(version)+'/job/name/'+str(job)+'/run?environmentName='+str(environment)

 x = requests.post(url, auth = (str(user),str(password)))

 res = json.loads(x.text)

 

 return res

 

 

print(lambda_handler({"jobname": "orchestration_test_success"}, 'test'))

 

 

 

 

Hi Nils,

 

Thank you for responding. My Bad there is a typo in the url i gave in the command. Now it is working.