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

Import json in Matillion using API

Hi,

I am trying to import a json in matillion to a specific project and group. I am using the following curl command :-

curl -X -u ec2-user:i-069fad7255685211f POST http://54.40.185.68:8080/rest/v0/projects?groupName=ghhusdw&projectName=test_ora -H "Content-Type: application/json" --data-binary @FIM_export.json.

But this throws anerror. Can you please suggest a solution to this?

7 Community Answers

Matillion Agent  

Ian Funnell —

Hi Aakarsh,

I suspect the error is saying it can’t import because the target project already exists? If so, you will need to either remove or rename the target project: it won’t overwrite an existing project.

If the error is concerning an invalid format, please note that the export/import format used by the API is different to the format used when you export/import from Matillion’s web user inteface. The two formats are both JSON but are not interchangeable.

Best regards,
Ian


Aakarsh Mohan —

Hi Ian,

I am trying to use the follwoing command with a new project name :-

curl -X -u ec2-user:i-069fa** POST http://54.40.185.68:8080/rest/v0/projects?groupName=ghhusdw&projectName=test -H "Content-Type: application/json" --data-binary @/home/ec2-user/work/FIM_export.json

It shows the following error :-

curl: (3) Illegal port number
curl: (6) Couldn't resolve host 'POST'
{"success":false,"msg":"HTTP 405 Method Not Allowed","id":-1}

Please note that i fire this command from the Matillion ec2 itself.

Thanks,
Aakarsh


Matillion Agent  

Kalyan Arangam —

hi Aakarsh

Are you running this from the BASH script component?

A few things to note -

  1. Try moving POST next to -X. so it should read “curl -X POST -u …”
  2. See if enclosing the URL in quotes helps (")
  3. Ignore this point if you run this command after you SSH as the ec2-user. If you are running this command from the BASH script component, it will run under the context of tomcat user and will not have access to the home directory of ec2-user. Please copy the JSON file to a commonly available directry (/tmp?).

Are you able to run this from your local machine? remember to get rid of port 8080 if you are running from outside matillion.

Best
Kalyan


Aakarsh Mohan —

Hi Kalyan,

I did move POST next to-X.
I do login in Matillion as ec2-user so didnt remove port 8080 and it has access to home directory of ec2-user.
Moreover, I did put the URL in quotes. It shows a different error now.

{"success":false,"msg":"Exactly one project group is expected when POSTing to /project","id":-1}

Can you please help me resolve this.
Thanks in advance.

Aakarsh


Matillion Agent  

Kalyan Arangam —

Hi Aakarsh,

Please note that ec2-user in matillion is different to the local-linux user ec2-user so the matillion will not have access to the ec2-user home-directory. As advised previously, please use the /tmp folder to hold the JSON files. Please see examples below.

As the error suggests, looks like the JSON file has more than one Project-Group. I am unable to comment further on this error without looking at your JSON file. Are you able to share your JSON that you are trying to import?

Below are two curl-commands I’ve used to Export a project and then POST it back to the server using the bash script component. Please note that I edited the project-name in the downloaded JSON file and saved the file as mtln_project_new.json.

Export
curl -o /tmp/mtln_project.json -X GET -u api-user:api-user -H “Content-Type: application/json” “https://127.0.0.1:8080/rest/v0/projects?groupName=Demonstration%20Projects&projectName=MyProject&versionName=default&export=true”

Import
curl -X POST -u api-user:api-user http://127.0.0.1:8080/rest/v0/projects -H “Content-Type: application/json” —data-binary @/tmp/mtln_kc_project.json

Parameters
Groupname – Demonstration Projects
ProjectName – MyProject
Export filename – /tmp/mtln_project_json
Import filename – /tmp/mtln_project_new.json
User/password – api-user/api-user

Hope that helps.

Best
Kalyan


Matillion Agent  

Kalyan Arangam —

Hi Aakarsh,

(corrected some mistakes in the command)

Please note that ec2-user in matillion is different to the local-linux user ec2-user so the matillion will not have access to the ec2-user home-directory. As advised previously, please use the /tmp folder to hold the JSON files. Please see examples below.

As the error suggests, looks like the JSON file has more than one Project-Group. I am unable to comment further on this error without looking at your JSON file. Are you able to share your JSON that you are trying to import?

Below are two curl-commands I’ve used to Export a project and then POST it back to the server using the bash script component. Please note that I edited the project-name in the downloaded JSON file and saved the file as mtln_project_new.json.

Export
curl -o /tmp/mtln_project.json -X GET -u api-user:api-user -H “Content-Type: application/json” “https://127.0.0.1:8080/rest/v0/projects?groupName=Demonstration%20Projects&projectName=MyProject&versionName=default&export=true”

Import
curl -X POST -u api-user:api-user “http://127.0.0.1:8080/rest/v0/projects” -H “Content-Type: application/json” —data-binary @/tmp/mtln_project_new.json

Parameters
Groupname – Demonstration Projects
ProjectName – MyProject
Export filename – /tmp/mtln_project.json
Import filename – /tmp/mtln_project_new.json
User/password – api-user/api-user

Hope that helps.

Best
Kalyan


Matillion Agent  

Ian Funnell —

Hi Aakarsh,

Hope you were able to get this working with the help of the above examples. Also please note that our v0 API documentation has been updated recently, so could be worth another look.

Best regards,
Ian

Post Your Community Answer

To add an answer please login