<?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 Re: Patch Authorization rules with PROC HTTP in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Patch-Authorization-rules-with-PROC-HTTP/m-p/900212#M355782</link>
    <description>&lt;P&gt;found the solution, had to add&amp;nbsp;"path": "/authorization/rules/" to the json input. it is working now:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let base_url = https://%scan(&amp;amp;_baseurl.,2,"/");
%put &amp;amp;base_url.;


	filename input temp ;
	filename output  temp ;
	filename header temp;
	
	
	proc stream outfile=input; begin &amp;amp;streamdelim; 
[
    {
        "op": "add",
		 "path": "/authorization/rules/",
        "value": {
            "description": "test",
            "objectUri": "/folders/folders/c7496325-eabf-474b-a499-e9de0ae5a6a1",
            "permissions": [
                "read",
                "update",
                "add",
                "remove"
            ],
            "principalType": "group",
            "principal": "test",
            "type": "grant"
        }
    },
    {
        "op": "add",
	"path": "/authorization/rules/",
        "value": {
            "description": "test",
            "containerUri": "/folders/folders/c7496325-eabf-474b-a499-e9de0ae5a6a1",
            "permissions": [
                "read",
                "update",
                "add",
                "remove",
                "delete"
            ],
            "principalType": "group",
            "principal": "test",
            "type": "grant"
        }
    }
]
;;;;
	
	proc http url="&amp;amp;base_url/authorization/rules" 
		oauth_bearer=sas_services 
		out=output
		in=input
		headerout=header
		method=patch;
		debug level = 2;
	headers 
		"Accept"="application/vnd.sas.collection+json"
		"Content-Type"="application/json-patch+json";
	run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 26 Oct 2023 20:08:09 GMT</pubDate>
    <dc:creator>marlo84</dc:creator>
    <dc:date>2023-10-26T20:08:09Z</dc:date>
    <item>
      <title>Patch Authorization rules with PROC HTTP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Patch-Authorization-rules-with-PROC-HTTP/m-p/900178#M355775</link>
      <description>&lt;P&gt;Hello SAS community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create folder authorization rules with PROC HTTP &amp;nbsp;by requesting the SAS Viya REST API. But I keep getting a '400 Bad Request'. My reference source &amp;nbsp;is a Python script - &amp;nbsp;&lt;A title="link" href="https://github.com/sassoftware/pyviyatools/blame/master/applyfolderauthorization.py" target="_self"&gt;link.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can create folders and usergroups&amp;nbsp;with the REST API.&lt;/P&gt;&lt;P&gt;How can I get this patch request working without Pyhton or CLI?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let base_url = https://%scan(&amp;amp;_baseurl.,2,"/");
%put &amp;amp;base_url.;

	
	filename input temp;
	filename output  temp ;
	filename header temp;
	
	proc stream outfile=input; begin &amp;amp;streamdelim; 
[
		{
			    "op":"add",
			    "value": {
						"description": "test",
						"objectUri":"/folders/folders/c7496325-eabf-474b-a499-e9de0ae5a6a1",
			             "permissions":["read", "update","secure","add","remove"],
			             "principalType":"group",
			             "principal":"test",
			             "type":"grant"
			             }
	  			},
			  {
			    "op":"add",
			    "value": {
						"description": "test",
			           "containerUri":"/folders/folders/c7496325-eabf-474b-a499-e9de0ae5a6a1",
			              "permissions":["read", "update","delete","add","remove"],
			             "principalType":"group",
			             "principal":"test",
			             "type":"grant"
			             }
		  }
]
	;;;;
	
	proc http url="&amp;amp;base_url/authorization/rules" 
		oauth_bearer=sas_services 
		out=output
		in=input
		headerout=header
		method=patch;
		debug level = 2;
	headers 
		"Accept"="application/vnd.sas.collection+json"
		"Content-Type"="application/json-patch+json";
	run;&lt;/PRE&gt;&lt;P&gt;response:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
	"errorCode": 0,
	"message": "Unable to parse valid patch operations from provided patch.",
	"details": [
		"traceId: 0c972600186e4596",
		"path: /authorization/rules"
	],
	"links": [],
	"version": 2,
	"httpStatusCode": 400
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 17:06:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Patch-Authorization-rules-with-PROC-HTTP/m-p/900178#M355775</guid>
      <dc:creator>marlo84</dc:creator>
      <dc:date>2023-10-26T17:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: Patch Authorization rules with PROC HTTP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Patch-Authorization-rules-with-PROC-HTTP/m-p/900212#M355782</link>
      <description>&lt;P&gt;found the solution, had to add&amp;nbsp;"path": "/authorization/rules/" to the json input. it is working now:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let base_url = https://%scan(&amp;amp;_baseurl.,2,"/");
%put &amp;amp;base_url.;


	filename input temp ;
	filename output  temp ;
	filename header temp;
	
	
	proc stream outfile=input; begin &amp;amp;streamdelim; 
[
    {
        "op": "add",
		 "path": "/authorization/rules/",
        "value": {
            "description": "test",
            "objectUri": "/folders/folders/c7496325-eabf-474b-a499-e9de0ae5a6a1",
            "permissions": [
                "read",
                "update",
                "add",
                "remove"
            ],
            "principalType": "group",
            "principal": "test",
            "type": "grant"
        }
    },
    {
        "op": "add",
	"path": "/authorization/rules/",
        "value": {
            "description": "test",
            "containerUri": "/folders/folders/c7496325-eabf-474b-a499-e9de0ae5a6a1",
            "permissions": [
                "read",
                "update",
                "add",
                "remove",
                "delete"
            ],
            "principalType": "group",
            "principal": "test",
            "type": "grant"
        }
    }
]
;;;;
	
	proc http url="&amp;amp;base_url/authorization/rules" 
		oauth_bearer=sas_services 
		out=output
		in=input
		headerout=header
		method=patch;
		debug level = 2;
	headers 
		"Accept"="application/vnd.sas.collection+json"
		"Content-Type"="application/json-patch+json";
	run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Oct 2023 20:08:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Patch-Authorization-rules-with-PROC-HTTP/m-p/900212#M355782</guid>
      <dc:creator>marlo84</dc:creator>
      <dc:date>2023-10-26T20:08:09Z</dc:date>
    </item>
  </channel>
</rss>

