How can I call the API to run an orchestration job using in-line job variable parameters

I have been following instructions from this Matillion blog post on how to call the API using a CURL command while passing values for job variables. Using the syntax, I am entering something like this:

 

curl -X POST –user <api_user>:<api_user_password> 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> -H "Content-Type: application/json" –data-binary '{"scalarVariables":{"target_schema":"TEST","target_table":"test_airport2"}}'

 

My job variables in the example above would be "target_schema" and "target_table". When I run curl commands without the post header (i.e. removing everything starting at -H) the API call works and runs the job fine.

 

This is the example given in the blog. I replaced the single and double quotes from the blog post with standard single/double quotes because the blog post had them formatted. I also noticed that some other references had an additional dash before -data-binary, so I also tried ---data-binary (2 dashes before data).

 

In all attempts, i get invalid URL syntax errors, including this one complaining about the single quote

{"success":false,"msg":"Unexpected character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 2].","id":-1}

 

and after tweaking the URL I get this one, which claims there is an extra bracket which does not seem right:

{"success":false,"msg":"Unexpected character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 2].","id":-1}curl: (3) unmatched close brace/bracket in URL position 40:

fake_client,job_geography_name:fake_geo}}'

 

There is a carat ^ in the output pointing to the second to last bracket above.

 

Any help would be appreciated.  

 

Hi there! Have you been able to run this command successfully? I can review the blog as the formatting does need to be updated to code blocks. I will also take a look at the commands you shared and what's in the blog to see what may be going on. I'll share an update as I review this. Thanks for your patience.

I figured this out after more digging, trial and error. The API call is for use by my client, and although they invoke the calls their own way, the syntax still had to be corrected from the references I found. I was using a Windows command-line window (cmd.exe) to make the call. This utility only likes double quotes. I restructured the syntax and it works. For the purposes of improving the Matillion knowledge base and hopefully its documentation, here is a format that worked for me:

 

curl --location "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>" --header "Content-Type: application/json" --header "Authorization: Basic <authorization>" --data "{   \"scalarVariables\": {       \"parameter_name1\": \"value1\",       \"parameter_name2\": \"value2\"   }}"

Thank you for your response and sharing this information. I will work on getting this updated in the blog and elsewhere if needed. Hope you have a great weekend!