I have come across a method where we get the sha code when we hit the github url but once i have done the get request and have the tree code as well as the shacode. Once i perform the post operation i am getting 404 as the error can you help regarding this. i have achieved the same using rest api but want to do the same using sas studio program that i have created .
%let user="username";
%let pass="personaltoken generated at githu";
filename eqty "/home/mystudiodirectory/test.txt" lrecl=32000;
proc http
url="https://api.github.com/repos/user/repos/git/refs/heads/master"
method="GET" out=eqty webusername=&user
webpassword=&pass
ct="application/text";
run;
data firstrequest;
infile "/home/mystudiodirectory0/test.txt" dsd lrecl=3000000;
input x : $2000. @@;
retain flag;
pos=find(x, "sha");
if(pos>0) then
do;
flag=1;
var=scan(x, 3, '""');
shalatestcommit=scan(x, 5, '""');
end;
run;
data request2(keep=shalatestcommit);
set firstrequest;
if var not in ('sha') then
delete;
call symput('shaltcommit', trim(shalatestcommit));
run;
/*******************************second request**************************/
%let url=https://api.github.com/repos/user/repository/git/commits/&shaltcommit.;
filename eqty1 "/home/mystudiodirectory0/test1.txt" lrecl=32000;
proc http url="&url" method="GET" out=eqty1 webusername=&user
webpassword=&pass
ct="application/text";
data secondrequest;
infile "/home/mystudiodirectory0/test1.txt" dsd lrecl=3000000;
input x : $2000. @@;
retain flag1;
pos=find(x, "tree");
if(pos>0) then
do;
flag1=1;
var=scan(x, 1, '""');
treecommit=scan(x, 5, '""');
end;
run;
data request3(keep=treecommit);
set secondrequest;
if var not in ('tree') then
delete;
call symput('treecommit', trim(treecommit));
run;
/************************************************************/
*filename eqty3 "/home/mystudiodirectory0/test3.txt";
/*data store;
y=compress(symget(&body));
file eqty3;
put y;
run;*/
filename eqty2 "/home/mystudiodirectory0/test2.txt" lrecl=32000;
data _null_;
infile datalines;
file eqty2;
input;
put _infile_;
datalines;
{
"base_tree": "treecommit value",
"tree": [
{
"path": "NewFile1.txt",
"mode": "100644",
"type": "blob",
"content": "This is NewFile1."
}
]
}
;
run;
filename eqty3 "/home/mystudiodirectory0/test3.txt" lrecl=32000;
;
proc http url="https://api.github.com/repos/user/repository/git/trees"
method="POST" in=eqty2 out=eqty3 webusername=&user
webpassword=&pass;
data thirdrequest;
infile "/home/mystudiodirectory0/test3.txt" dsd lrecl=3000000;
input x : $2000. @@;
retain flag2;
pos=find(x, "sha");
if(pos>0) then
do;
flag2=1;
var=scan(x, 1, '""');
nwshalatestcommit=scan(x, 3, '""');
end;
run;
... View more