<?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: PROC HTTP - ServiceNow URL help needed in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-ServiceNow-URL-help-needed/m-p/812284#M81802</link>
    <description>Yeah.....they don't provide that. Their policy is to give no guidance - none - zero - we're on our own - on writing APIs. So....question is still open to anyone who can help provide clues.</description>
    <pubDate>Tue, 10 May 2022 02:30:44 GMT</pubDate>
    <dc:creator>Bruno7</dc:creator>
    <dc:date>2022-05-10T02:30:44Z</dc:date>
    <item>
      <title>PROC HTTP - ServiceNow URL help needed</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-ServiceNow-URL-help-needed/m-p/812267#M81800</link>
      <description>&lt;P&gt;I want to be able to&lt;BR /&gt;1) read ServiceNow for all unassigned sc tasks under my group&lt;BR /&gt;2) read ServiceNow again to obtain the corresponding RITM numbers for each task (we need bits of information from the sc task as well as from the RITM in order to process the ServiceNow request)&lt;BR /&gt;3) Update the sc task to show work is in progress and that it has been assigned to the automated process&lt;BR /&gt;&lt;BR /&gt;I know this can be done, but am having trouble finding the correct URL syntax that will do items 2 and 3. Here is the syntax I found that does accomplish item #1 and brings back every unassigned sc task out there.&amp;nbsp; Now I just need to match each task with its RITM, and update the task to show it is work in progress and assigned:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;libname mylib "/mydir/myfolder/";

%macro get_unassigned_task();
	%LET unpw =xxxxxxxxxxx
		DATA _NULL_;
	call symput('encode',put("&amp;amp;unpw",$base64X76.));
	RUN;

	filename response TEMP;
	filename headers TEMP;
	%let url_query=%nrstr(https://mysite.service-now.com/api/now/table/task?sysparm_query=name%3D);
	%let url_query_cont=%nrstr(&amp;amp;assignment_group=MYASSIGNMENTGROUP);
	%put &amp;amp;url_query.&amp;amp;url_query_cont;
	options set= SSLCALISTLOC="/sas/sas94m5install/SASSecurityCertificateFramework/1.1/cacerts/cacerts.pem";

	PROC HTTP

		url="&amp;amp;url_query.&amp;amp;url_query_cont."	

		out=response
		headerout=headers;
		headers
			"Accept"="application/json"
			"Content-Type"="application/json"
			"Authorization"=" Basic &amp;amp;encode";
	RUN;

	LIBNAME RESPONSE JSON fileref=response;

	PROC SQL NOPRINT;
		SELECT count(*) into :total_obs FROM RESPONSE.ALLDATA;
	QUIT;

	%if &amp;amp;total_obs &amp;gt; 1 %then
		%do;

			PROC SQL NOPRINT;
				SELECT * INTO :my_vAR FROM RESPONSE.RESULT;
			quit;

			proc sql noprint;
				create table mylib.active as 
					select * from RESPONSE.RESULT
						where 
							sys_class_name = "sc_task" and
							assigned_to = "" and
							active="true"
				;
			quit;

			data mylib.active_in_progress;
				set mylib.active;
			run;

			RUN;

		%end;
	%else
		%do;
			%PUT No unassigned tasks were found for workgroup MYASSIGNMENTGROUP.;
		%end;
%mend;

%get_unassigned_task()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been all over the ServiceNow site, so far, I have nothing:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developer.servicenow.com/dev.do#!/learn/learning-plans/sandiego/new_to_servicenow/app_store_learnv2_buildneedit_sandiego_tables" target="_blank" rel="noopener"&gt;Tables | ServiceNow Developers&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Can someone please advise? Spinning my wheels a bit....&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 21:53:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-ServiceNow-URL-help-needed/m-p/812267#M81800</guid>
      <dc:creator>Bruno7</dc:creator>
      <dc:date>2022-05-09T21:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP - ServiceNow URL help needed</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-ServiceNow-URL-help-needed/m-p/812275#M81801</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416286"&gt;@Bruno7&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;This is something your ServiceNow team will provide.&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 23:39:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-ServiceNow-URL-help-needed/m-p/812275#M81801</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-05-09T23:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP - ServiceNow URL help needed</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-ServiceNow-URL-help-needed/m-p/812284#M81802</link>
      <description>Yeah.....they don't provide that. Their policy is to give no guidance - none - zero - we're on our own - on writing APIs. So....question is still open to anyone who can help provide clues.</description>
      <pubDate>Tue, 10 May 2022 02:30:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-ServiceNow-URL-help-needed/m-p/812284#M81802</guid>
      <dc:creator>Bruno7</dc:creator>
      <dc:date>2022-05-10T02:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP - ServiceNow URL help needed</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-ServiceNow-URL-help-needed/m-p/812363#M81803</link>
      <description>&lt;P&gt;Your URL as it would be resolved is:&lt;/P&gt;
&lt;PRE&gt;https://mysite.service-now.com/api/now/table/task?sysparm_query=name%3D&amp;amp;assignment_group=MYASSIGNMENTGROUP&lt;/PRE&gt;
&lt;P&gt;The %3D is a URL-encoded = symbol. This construct doesn't seem correct to me. I think you mean to provide a value for sysparm_query and that whatever follows has to be URL encoded to pass through to the API. So "empty value" for "name=" -- is that correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Usually I try working the problem with Postman to validate the API calls, then transcribe to SAS to operationalize them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe it's something like this?&lt;/P&gt;
&lt;PRE&gt;	%let url_query=https://mysite.service-now.com/api/now/table/task?sysparm_query=;
	%let url_query_cont=%sysfunc(urlencode(name=%str(&amp;amp;)assignment_group=MYASSIGNMENTGROUP));
	%put &amp;amp;url_query.&amp;amp;url_query_cont;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 May 2022 11:28:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-ServiceNow-URL-help-needed/m-p/812363#M81803</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-05-10T11:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP - ServiceNow URL help needed</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-ServiceNow-URL-help-needed/m-p/848603#M82361</link>
      <description>&lt;P&gt;Hoping Chris H sees this...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it is many months later and we have been in production with our first SAS-to-ServiceNow API to automate a mundane task (hooray!),&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I have a new problem:&amp;nbsp; how do I do the java "getDisplayValue()" but in SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Results of my query in Postman.&amp;nbsp; I need the display value of the "assigned_to" field, but I don't know how to code for that in SAS.&amp;nbsp; Or is there some way I can modify my URL query string to get at that display value?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my query string:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://blah.service-now.com/api/now/table/sc_task?sysparm_query=active=true^" target="_blank"&gt;https://blah.service-now.com/api/now/table/sc_task?sysparm_query=active=true^&lt;/A&gt;assignment_group=3f4f95db13e712003794b86f3244b0d0&amp;amp;sysparm_display_value=true&amp;amp;sysparm_fields=assigned_to,due_date,number,sys_id&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="Bruno7_0-1670524420207.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78199iE2D723EC46D0F6BB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bruno7_0-1670524420207.png" alt="Bruno7_0-1670524420207.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 18:35:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-ServiceNow-URL-help-needed/m-p/848603#M82361</guid>
      <dc:creator>Bruno7</dc:creator>
      <dc:date>2022-12-08T18:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP - ServiceNow URL help needed</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-ServiceNow-URL-help-needed/m-p/848605#M82362</link>
      <description>&lt;P&gt;In case other SAS developers happen across this post - here was the solution for us.&amp;nbsp; Hope it helps as starter code for someone!&amp;nbsp; (Also:&amp;nbsp; install Postman, as Chris H mentioned.&amp;nbsp; Use it to build your basic query, then translate it in the SAS code, as shown in the "%let url_query = ...")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro get_task();
	%LET unpw =username:password;
	DATA _NULL_;
		call symput('encode',put("&amp;amp;unpw",$base64X76.));
	RUN;
	filename SSSNGIT1 TEMP;
	filename headers TEMP;
	%let url_query=%nrstr(https://blahtage.service-now.com/api/now/table/sc_task?sysparm_query=active=true^assignment_group=3f4f95db13e712003794b86f3244b0d0);
	%put &amp;amp;url_query;
	options set= SSLCALISTLOC="/sas/sas94m5install/SASSecurityCertificateFramework/1.1/cacerts/cacerts.pem";
	PROC HTTP
		url="&amp;amp;url_query."	

		out=SSSNGIT1
		headerout=headers;
		headers
			"Accept" = "application/json"
			"Content-Type" = "application/json"
			"Authorization" = " Basic &amp;amp;encode";
	RUN;
	LIBNAME SSSNGIT1 JSON fileref=SSSNGIT1;
	PROC SQL;
		SELECT count(*) into :total_obs FROM SSSNGIT1.ALLDATA;
	QUIT;
	%if	&amp;amp;total_obs &amp;gt; 1 %then
		%do;
			PROC SQL;
				SELECT * INTO :my_vAR FROM SSSNGIT1.RESULT;
			quit;
			libname SSSNGIT2 "/hpsasfin/prod/projects/inf/fnd/prod/data/SSSN/STAGE/";
			proc sql;
				create table SSSNGIT2.SSSN_GITHUB2_task_order as 
					select * from SSSNGIT1.RESULT
						where 
							sys_class_name = "sc_task" and
							active="true" and
							u_reference_2 = "SAS Code" and 
							u_reference_3 = "GitHub" and
/*							assigned_to = "" and*/
							state="1" 
						order by number
				;
			quit;
%end;
%mend;
%get_task();&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; (&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 18:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-ServiceNow-URL-help-needed/m-p/848605#M82362</guid>
      <dc:creator>Bruno7</dc:creator>
      <dc:date>2022-12-08T18:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP - ServiceNow URL help needed</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-ServiceNow-URL-help-needed/m-p/848617#M82364</link>
      <description>&lt;P&gt;Sounds like you got it going and all solved? I had just worked up a simple JSON read example but your code looks like it's covered.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;filename json temp;
 
data _null_;
 file json;
 infile datalines;
 input;
 put _infile_;
datalines;
{
"result": [{
  "number": "SCTASK3054528",
  "sys_id": "02b09ba4db6f59d0acd5aa2el39619b3", 
  "due_date": "12/01/2022 14:02:51",
  "assigned_to": {
   "display_value": "the display value",
   "link": "https://snlink.com/api/now/table/sysuser/9d5779034f5a7604df3497dd0210c7e3"
  }
}]
}
run;

data _null_;
 rc=jsonpp('json','log');
run;

libname resp JSON fileref=json;
proc print data=resp.alldata;
run;&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 08 Dec 2022 19:25:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-ServiceNow-URL-help-needed/m-p/848617#M82364</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-12-08T19:25:31Z</dc:date>
    </item>
  </channel>
</rss>

