Skip to main content

Rest API command to import pipeline/jobs in control hub

  • March 8, 2022
  • 1 reply
  • 335 views

Sami
StreamSets Employee
  • StreamSets Employee

Question:

  • How to import pipelines/jobs in the control hub using Rest API?

Answer:

Command to generate cookie:

curl -X POST -d '{"userName":"<username>", "password": "<password>"}' https://cloud.streamsets.com/security/public-rest/v1/authentication/login --header "Content-Type:application/json" --header "X-Requested-By:SCH" -c cookie.txt

Generated session token:

sessionToken=$(cat cookie.txt | grep SSO | rev | grep -o '^\S*' | rev)
echo "Generated session token : $sessionToken"

Import pipelines:

curl -v 'https://cloud.streamsets.com/pipelinestore/rest/v1/pipelines/importPipelineCommits' -F "file=@/<path>/<pipelineName>.zip" -H "X-Requested-By:SCH" -H "Content-Type:multipart/form-data" -H "Accept-Encoding: gzip, deflate" --header "X-SS-User-Auth-Token:$sessionToken" -i

Import jobs:

curl -v 'https://cloud.streamsets.com/jobrunner/rest/v1/jobs/importJobs' -F "file=@/<path>/jobs.zip" -H "X-Requested-By:SCH" -H "Content-Type:multipart/form-data" -H "Accept-Encoding: gzip, deflate" --header "X-SS-User-Auth-Token:$sessionToken" -i

 

Troubleshooting Steps:

  1. Make sure you have @ in the file attribute -F "file=@/<path>"
  2. For importPipelineCommits/importJobs use zip file.
  3. If possible, import the pipeline/job manually in the control hub and see whether its successfully.
  4. If the import is unsuccessful, check the commit.id of the pipeline/job, it should be unique.
Did this topic help you find an answer to your question?

1 reply

nchalla0
Fan
  • Fan
  • 2 replies
  • June 20, 2023

I followed the same steps as above but getting below error

curl  -v -X POST 'https://cloud.streamsets.com/pipelinestore/rest/v1/pipelines/importPipelineCommits' -F "file=@~/Desktop/navsdc.zip" -H "X-Requested-By:SCH" -H "Content-Type:multipart/form-data" -H "Accept-Encoding: gzip, deflate" --header "X-SS-User-Auth-Token:$sessionToken" -i
curl: (26) Failed to open/read local data from file/application

The zip file Iam using is exported from the streamsets using export API, Any Suggestions?


Reply