Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Python Restful Call 404 not found

Getting a 404 with REST call. I know the credentials are ok because if I change or disable the API user property I get a credential issue so unsure why am getting a 404

Job Details are correct (version, project,group,environment and job). Job is below a folder which should be ok since jobnames are unique

example call

data = {
"groupName" : 'cervello',
"projectName" : 'myproject',
"versionName" : 'default',
"environmentName" : 'Snowflake',
"jobName" : 'OrcStageCustomer'
}

data=json.dumps(data)

url='http://myurl/rest/v1/tasks'
response = requests.post(url, headers=headers,data=data,auth=('myid', 'mypw'))

python response

<Response [404]>

and if i change to invalid user

<Response [401]>

so i now connection and security is good so not sure why I am getting a 404


8 Community Answers

brian swarbrick —

FYI
It does work with CURL just getting issue via REST python call


Matillion Agent  

David Lipowitz —

Hi Brian,

Can you please try your Python call

  1. without translating the data dict using json.dumps and
  2. using the json parameter instead of the data parameter

e.g.

data = {
    "groupName" : 'cervello',
    "projectName" : 'myproject',
    "versionName" : 'default',
    "environmentName" : 'Snowflake',
    "jobName" : 'OrcStageCustomer'
}
url='http://myurl/rest/v1/tasks'
response = requests.post(url, headers=headers,json=data,auth=('myid', 'mypw'))

Hope that helps and please let us know if you need more support on this.

Best Regards,
Dave


brian swarbrick —

still 404 trying this and other variations

also I am using the v0 call (v1 gives a 500 error)

wonder if its something in the header?


headers= {
"Content-Type":"application/json; charset=UTF-8",
"Accept":"application/json"
}
data = {
"groupName" : 'cervello',
"projectName" : 'myproject',
"versionName" : 'default',
"environmentName" : 'Snowflake',
"jobName" : 'OrcStageCustomer'
}
#data=json.dumps(data)
url='http://validurl/rest/v0/tasks'
response = requests.post(url, headers=headers,json=data,auth=('xxxxx','xxxx'))
print(response)


brian swarbrick —

looks like this may be working

params=data


brian swarbrick —

so i can start a job using params=data in the requests call which is good. I get a return of 200 also. do u know what I need to modify to return the job id that comes back as part of the curl?

thanks


Matillion Agent  

David Lipowitz —

Hi Brian,

FYI, using the json parameter instead of data should set those headers by default.

In this case though, it isn’t needed. When initiating tasks through the API, we recommend the following:

url = 'http://{ip}/rest/v1/group/name/{group_name}/project/name/{project_name}/version/name/{version_name}/job/name/{job_name}/run'.format(
    ip=ip,
    group_name=group_name,
    project_name=project_name,
    version_name=version_name,
    job_name=job_name
)
resp = requests.post(
    url,
    auth=HTTPBasicAuth(user, pw)
)

Hope that helps and please let us know if you have more questions.

Best Regards,
Dave


brian swarbrick —

Thanks
I was able to get the old code working (below) as expected (v0) - so seems ok. I get 500 responses with the v1 test

This is working though

headers= {
"Content-Type":"application/json; charset=UTF-8",
"Accept":"application/json"
}
data = {
"groupName" : "cervello",
"projectName" : "myproject",
"versionName" : "default",
"environmentName" : "Snowflake",
"jobName" : "OrcStageCustomer"
}

url='http://myip/rest/v0/tasks'
response = requests.post(url, headers=headers,params=data,auth=('id','pw'))

data=response.json()
print(data)
print('ID is ' + str(data['id']))


brian swarbrick —

V1 works now all good thanjs

Post Your Community Answer

To add an answer please login