<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Copy Job Definition using REST API or CLI in Administration and Deployment</title>
    <link>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/712669#M21276</link>
    <description>&lt;P&gt;Hello community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We need to automate the process of a copying of existing jobs "Job Definition" .&lt;/P&gt;
&lt;P&gt;The information I found is very limited:&lt;/P&gt;
&lt;P&gt;1. Using CLI&lt;/P&gt;
&lt;P&gt;For CLI&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=calcdc&amp;amp;cdcVersion=3.5&amp;amp;docsetId=caljobs&amp;amp;docsetTarget=p1g6z2wnbs79lun1n5556kigta2h.htm&amp;amp;locale=en"&gt;SAS Help Center: Scheduling Command Line Interface &lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I'm able to create a new&amp;nbsp;jobDefinitions file using CLI&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sas-admin.exe -k job definitions create --file-in "&amp;lt;path&amp;gt;\template.txt"&lt;/P&gt;
&lt;P&gt;the content of template file:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"name": "New Job",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"type": "jobDefinition",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"code": ""&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The JobDefinition is created, but I don't understand how I can use it. There is no information about parentFolder and I can't reuse it in the Environment Manager.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Using REST API&lt;/P&gt;
&lt;P&gt;I found this piece of code&amp;nbsp;&lt;A href="https://developer.sas.com/apis/rest/v3.5/Compute/?python#create-a-job-definition" target="_blank" rel="noopener"&gt;Compute – Visualization API Reference (sas.com)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I haven't tried it, but it seems to be similar to the CLI. I don't have parentFolderURI and can't process it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please help me to understand what is wrong and what steps should be done to copy existing Job1 to a new Job2 using REST API or CLI?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;Ivan&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jan 2021 13:16:05 GMT</pubDate>
    <dc:creator>idziemianczyk</dc:creator>
    <dc:date>2021-01-20T13:16:05Z</dc:date>
    <item>
      <title>Copy Job Definition using REST API or CLI</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/712669#M21276</link>
      <description>&lt;P&gt;Hello community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We need to automate the process of a copying of existing jobs "Job Definition" .&lt;/P&gt;
&lt;P&gt;The information I found is very limited:&lt;/P&gt;
&lt;P&gt;1. Using CLI&lt;/P&gt;
&lt;P&gt;For CLI&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=calcdc&amp;amp;cdcVersion=3.5&amp;amp;docsetId=caljobs&amp;amp;docsetTarget=p1g6z2wnbs79lun1n5556kigta2h.htm&amp;amp;locale=en"&gt;SAS Help Center: Scheduling Command Line Interface &lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I'm able to create a new&amp;nbsp;jobDefinitions file using CLI&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sas-admin.exe -k job definitions create --file-in "&amp;lt;path&amp;gt;\template.txt"&lt;/P&gt;
&lt;P&gt;the content of template file:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"name": "New Job",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"type": "jobDefinition",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"code": ""&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The JobDefinition is created, but I don't understand how I can use it. There is no information about parentFolder and I can't reuse it in the Environment Manager.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Using REST API&lt;/P&gt;
&lt;P&gt;I found this piece of code&amp;nbsp;&lt;A href="https://developer.sas.com/apis/rest/v3.5/Compute/?python#create-a-job-definition" target="_blank" rel="noopener"&gt;Compute – Visualization API Reference (sas.com)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I haven't tried it, but it seems to be similar to the CLI. I don't have parentFolderURI and can't process it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please help me to understand what is wrong and what steps should be done to copy existing Job1 to a new Job2 using REST API or CLI?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;Ivan&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2021 13:16:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/712669#M21276</guid>
      <dc:creator>idziemianczyk</dc:creator>
      <dc:date>2021-01-20T13:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Job Definition using REST API or CLI</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/714284#M21298</link>
      <description>&lt;P&gt;You need to also create a jobRequest, that is what is displayed in Environment Manager's schedule list:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the CLI:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/?cdcId=calcdc&amp;amp;cdcVersion=3.5&amp;amp;docsetId=caljobs&amp;amp;docsetTarget=p1g6z2wnbs79lun1n5556kigta2h.htm&amp;amp;locale=en"&gt;https://go.documentation.sas.com/?cdcId=calcdc&amp;amp;cdcVersion=3.5&amp;amp;docsetId=caljobs&amp;amp;docsetTarget=p1g6z2wnbs79lun1n5556kigta2h.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In the REST API:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://developer.sas.com/apis/rest/v3.5/Compute/#create-a-job-request" target="_blank"&gt;https://developer.sas.com/apis/rest/v3.5/Compute/#create-a-job-request&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 14:56:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/714284#M21298</guid>
      <dc:creator>gwootton</dc:creator>
      <dc:date>2021-01-26T14:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Job Definition using REST API or CLI</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/719681#M21549</link>
      <description>&lt;P&gt;I can create JobDefinition and then JobExecution, I can see the job using rest API query&lt;/P&gt;
&lt;P&gt;GET&amp;nbsp;&lt;A href="https://pvmict002.health.fgov.be/jobDefinitions/definitions?filter=eq(name,'D_JOB_COB_cd_v1_2_02_dashboard_wrapper')" target="_blank"&gt;https://&amp;lt;servername&amp;gt;/jobDefinitions/definitions?filter=eq(name,'&amp;lt;jobname&amp;gt;')&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but I can't see the job in the Env Manager.&amp;nbsp;No wonder, there are no&amp;nbsp;parentFolderUri parameter in query and body parameter.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I try to add parentFolderUri&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;A href="https://pvmict002.health.fgov.be/jobDefinitions/definitions" target="_blank"&gt;https://pvmict002.health.fgov.be/jobDefinitions/definitions&lt;/A&gt;?&lt;STRONG&gt;parentFolderUri&lt;/STRONG&gt;=/folders/folders/cc993804-82e2-477c-ad4e-d5039a441554&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have error:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Unable to add job definition to parent folder. Http status: 403.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I didn't find any "working" example of creation and reusing&amp;nbsp;JobDefinition and&amp;nbsp;JobExecution with folders. Do you have any ideas how to set the &lt;EM&gt;&lt;STRONG&gt;parentFolderUri &lt;/STRONG&gt;&lt;/EM&gt;for the jobs?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2021 17:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/719681#M21549</guid>
      <dc:creator>idziemianczyk</dc:creator>
      <dc:date>2021-02-16T17:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Job Definition using REST API or CLI</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/719683#M21550</link>
      <description>Do you have permission to write to that folder? Are you creating a new definition or trying to modify your existing one? &lt;BR /&gt;&lt;A href="https://developer.sas.com/apis/rest/v3.5/Compute/#create-a-job-definition" target="_blank"&gt;https://developer.sas.com/apis/rest/v3.5/Compute/#create-a-job-definition&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://developer.sas.com/apis/rest/v3.5/Compute/#update-a-job-definition" target="_blank"&gt;https://developer.sas.com/apis/rest/v3.5/Compute/#update-a-job-definition&lt;/A&gt;</description>
      <pubDate>Tue, 16 Feb 2021 17:18:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/719683#M21550</guid>
      <dc:creator>gwootton</dc:creator>
      <dc:date>2021-02-16T17:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Job Definition using REST API or CLI</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/719688#M21551</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Do you have permission to write to that folder?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;- I have the permission to modify the folder.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you creating a new definition or trying to modify your existing one?&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;- I created a new one. It looks OK but there is no link to any folder. I suppose this is the reason why I can't find the job in Env Manager.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dandycomp_1-1613496529438.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54798iFC1074EC9D7386CC/image-size/large?v=v2&amp;amp;px=999" role="button" title="dandycomp_1-1613496529438.png" alt="dandycomp_1-1613496529438.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dandycomp_2-1613496546828.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54799i121287CA0F7B0840/image-size/large?v=v2&amp;amp;px=999" role="button" title="dandycomp_2-1613496546828.png" alt="dandycomp_2-1613496546828.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="tinyMceEditordandycomp_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2021 17:31:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/719688#M21551</guid>
      <dc:creator>idziemianczyk</dc:creator>
      <dc:date>2021-02-16T17:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Job Definition using REST API or CLI</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/719694#M21552</link>
      <description>&lt;P&gt;I was able to create the jobDefinition in a folder by sending a POST containing the example job definition from developer.sas.com:&lt;/P&gt;
&lt;LI-CODE lang="json"&gt;{
  "version":2,
  "name":"Simple proc print",
  "description":"Show the contents of sashelp.class using PROC PRINT",
  "type":"Compute",
  "parameters":[
        {
        "version": 1,
        "name": "_contextName",
        "defaultValue": "SAS Job Execution compute context",
        "type": "CHARACTER",
        "label": "Context Name",
        "required": false
    }
  ],
  "code":"ods html style=HTMLBlue;\nproc print data=sashelp.class; run; quit;\nods html close;"
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp; to&amp;nbsp;&lt;SPAN class="resolvedVariable"&gt;&lt;SPAN data-offset-key="5c379-0-0"&gt;{{baseurl}&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="resolvedVariable"&gt;&lt;SPAN data-offset-key="5c379-0-0"&gt;}&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN data-offset-key="5c379-1-0"&gt;/jobDefinitions/definitions?parentFolderUri=/folders/folders/a3c382dc-0de3-41d1-9e96-a3c7c20ab23c (this is the URI of a folder in My Folder) along with my bearer token in the header and it created successfully.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gwootton_0-1613500774261.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54800iA12AC64CB652D550/image-size/medium?v=v2&amp;amp;px=400" role="button" title="gwootton_0-1613500774261.png" alt="gwootton_0-1613500774261.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2021 18:40:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/719694#M21552</guid>
      <dc:creator>gwootton</dc:creator>
      <dc:date>2021-02-16T18:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Job Definition using REST API or CLI</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/719822#M21553</link>
      <description>&lt;P&gt;I tested and it works for "MyFolder" too &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The strange thing it doesn't work for another folder(from my example). User assigned to group with write access(tested the same steps with ENV manager and JobExecution and the user can create a job).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, the good news we know that query is ok and I need to solve credential problems issue. Thanks a lot for the help.&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 08:03:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/719822#M21553</guid>
      <dc:creator>idziemianczyk</dc:creator>
      <dc:date>2021-02-17T08:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Job Definition using REST API or CLI</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/719912#M21556</link>
      <description>This probably has to do with the scope of the client being used when you get your bearer token. If the scope isn't * or specifies the group granting permission to the folder, it won't be included in the token, so permissions honored will only be those directly assigned to the user (like those of My Folder).</description>
      <pubDate>Wed, 17 Feb 2021 14:36:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Copy-Job-Definition-using-REST-API-or-CLI/m-p/719912#M21556</guid>
      <dc:creator>gwootton</dc:creator>
      <dc:date>2021-02-17T14:36:16Z</dc:date>
    </item>
  </channel>
</rss>

