<?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 how to set jobs permission with rest api in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-set-jobs-permission-with-rest-api/m-p/38789#M26762</link>
    <description>&lt;P&gt;create job with cli, but can not set the permission with cli,&lt;BR /&gt;have to use rest api to set permission:&lt;BR /&gt;&lt;A href="https://docs.databricks.com/api/workspace/permissions/set" target="_blank"&gt;https://docs.databricks.com/api/workspace/permissions/set&lt;/A&gt;&lt;/P&gt;&lt;P&gt;below is my command in windows to set permission:&lt;BR /&gt;curl -X PUT &lt;A href="https://my-workspace-url.azuredatabricks.net/api/2.0/permissions/jobs/my-job-id^" target="_blank"&gt;https://my-workspace-url.azuredatabricks.net/api/2.0/permissions/jobs/my-job-id^&lt;/A&gt;&lt;BR /&gt;-H "Authorization: Bearer my-personal-token" ^&lt;BR /&gt;-H "Content-Type: application/json" ^&lt;BR /&gt;--data "{\"access_control_list\":[{\"user_name\": \"xxx@company.com\", \"permission_level\": \"CAN_VIEW\"}]}"&lt;/P&gt;&lt;P&gt;I got below error message:&lt;BR /&gt;{"error_code":"INVALID_PARAMETER_VALUE","message":"The job must have exactly one owner."}&lt;BR /&gt;&lt;BR /&gt;anybody have the experience?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
    <pubDate>Mon, 31 Jul 2023 15:51:08 GMT</pubDate>
    <dc:creator>guostong</dc:creator>
    <dc:date>2023-07-31T15:51:08Z</dc:date>
    <item>
      <title>how to set jobs permission with rest api</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-set-jobs-permission-with-rest-api/m-p/38789#M26762</link>
      <description>&lt;P&gt;create job with cli, but can not set the permission with cli,&lt;BR /&gt;have to use rest api to set permission:&lt;BR /&gt;&lt;A href="https://docs.databricks.com/api/workspace/permissions/set" target="_blank"&gt;https://docs.databricks.com/api/workspace/permissions/set&lt;/A&gt;&lt;/P&gt;&lt;P&gt;below is my command in windows to set permission:&lt;BR /&gt;curl -X PUT &lt;A href="https://my-workspace-url.azuredatabricks.net/api/2.0/permissions/jobs/my-job-id^" target="_blank"&gt;https://my-workspace-url.azuredatabricks.net/api/2.0/permissions/jobs/my-job-id^&lt;/A&gt;&lt;BR /&gt;-H "Authorization: Bearer my-personal-token" ^&lt;BR /&gt;-H "Content-Type: application/json" ^&lt;BR /&gt;--data "{\"access_control_list\":[{\"user_name\": \"xxx@company.com\", \"permission_level\": \"CAN_VIEW\"}]}"&lt;/P&gt;&lt;P&gt;I got below error message:&lt;BR /&gt;{"error_code":"INVALID_PARAMETER_VALUE","message":"The job must have exactly one owner."}&lt;BR /&gt;&lt;BR /&gt;anybody have the experience?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2023 15:51:08 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-set-jobs-permission-with-rest-api/m-p/38789#M26762</guid>
      <dc:creator>guostong</dc:creator>
      <dc:date>2023-07-31T15:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to set jobs permission with rest api</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-set-jobs-permission-with-rest-api/m-p/39391#M26957</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This error message occurs because the Databricks REST API requires that every job have exactly one owner. When you try to set permissions using the API, you are required to specify the owner of the job using the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;owner&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;field in the job metadata.&lt;/P&gt;&lt;P&gt;To resolve this issue, you need to make sure that the job has exactly one owner specified in the job metadata. You can update the job metadata using the Databricks CLI or API. Here is an example of how to update the job metadata using the Databricks API:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;text&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;#&amp;nbsp;set&amp;nbsp;variables&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;TOKEN="&amp;lt;databricks-token&amp;gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;JOB_ID="&amp;lt;job-id&amp;gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;USERNAME="&amp;lt;username&amp;gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;#&amp;nbsp;get&amp;nbsp;current&amp;nbsp;job&amp;nbsp;metadata&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;JOB_META=`curl&amp;nbsp;-s&amp;nbsp;-X&amp;nbsp;GET&amp;nbsp;-H&amp;nbsp;"Authorization:&amp;nbsp;Bearer&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;${TOKEN}"&amp;nbsp;"https://&amp;lt;databricks-instance&amp;gt;/api/2.0/&lt;/SPAN&gt;&lt;SPAN class=""&gt;jobs/get?job_id=${JOB_ID}"`&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;#&amp;nbsp;parse&amp;nbsp;job&amp;nbsp;metadata&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;JOB_META_JSON=$(echo&amp;nbsp;"${JOB_META}"&amp;nbsp;|&amp;nbsp;jq&amp;nbsp;'.job')&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;#&amp;nbsp;set&amp;nbsp;owner&amp;nbsp;in&amp;nbsp;job&amp;nbsp;metadata&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;JOB_META_JSON=`echo&amp;nbsp;"${JOB_META_JSON}"&amp;nbsp;|&amp;nbsp;jq&amp;nbsp;".owne&lt;/SPAN&gt;&lt;SPAN class=""&gt;r_username=\"${USERNAME}\""`&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;#&amp;nbsp;update&amp;nbsp;job&amp;nbsp;metadata&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;curl&amp;nbsp;-s&amp;nbsp;-X&amp;nbsp;POST&amp;nbsp;-H&amp;nbsp;"Authorization:&amp;nbsp;Bearer&amp;nbsp;${TOKEN}&lt;/SPAN&gt;&lt;SPAN class=""&gt;"&amp;nbsp;"https://&amp;lt;databricks-instance&amp;gt;/api/2.0/jobs/rese&lt;/SPAN&gt;&lt;SPAN class=""&gt;t"&amp;nbsp;\&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp;-d&amp;nbsp;"{\"job_id\":&amp;nbsp;\"${JOB_ID}\",&amp;nbsp;\"new_settings\"&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&amp;nbsp;${JOB_META_JSON}}"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;This script uses the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;curl&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;command and the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;jq&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;command-line JSON processor to retrieve the current job metadata, add the specified owner to the job metadata, and then update the job with the new metadata.&lt;/P&gt;&lt;P&gt;Replace&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;databricks-token&amp;gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;with your Databricks token,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;job-id&amp;gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;with the ID of your job, and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;username&amp;gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;with the username of the owner you want to set. This script will update the job metadata to set&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;username&amp;gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;as the sole owner of the job.&lt;/P&gt;&lt;P&gt;After setting the owner in the job metadata, you should be able to set permissions using the Databricks REST API without encountering the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;"The job must have exactly one owner."&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;error message.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 16:14:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-set-jobs-permission-with-rest-api/m-p/39391#M26957</guid>
      <dc:creator>youssefmrini</dc:creator>
      <dc:date>2023-08-08T16:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to set jobs permission with rest api</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-set-jobs-permission-with-rest-api/m-p/43671#M27533</link>
      <description>&lt;P&gt;thank you, the new permission list should be a whole list, not the new permission&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 15:40:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-set-jobs-permission-with-rest-api/m-p/43671#M27533</guid>
      <dc:creator>guostong</dc:creator>
      <dc:date>2023-09-05T15:40:19Z</dc:date>
    </item>
  </channel>
</rss>

