I had a question regarding background http requests that @Craige_Hales answered.
https://community.jmp.com/t5/Uncharted/Can-JMP-run-JMP/ba-p/283748#U283748
I then took his code and modified it to do something like what you are looking for. In my case I was querying over different dates but you can modify the code to loop over whatever you want. You will probably need to make some adjustments depending on your specific use case.
Hopefully this helps.
url = "www....";
//Using this to generate different queries
query_keys = Associative Array();
query_keys["key1"] ="Bob"; //Or whatever your query parameters are
//I am looping over different dates
days_back = 20;
day_inc = 2;
start = Date Increment(today(),"day",-days_back);
end = Today();
cur_start = Date Increment(today(),"day",-day_inc);
cur_end = end;
index = 1;
//Here I am making files that contain the url and query key for each http request. I will use these later. This is only really needed if you intent to parallelize the http requset among multiple jmp instances.
//If you don't want to parallelize the queries you can skip the writing to disk and just make a list of your query keys and/or urls.
while(cur_end>start,
query_key["startdate"] = char(Format(cur_start,"yyyy-mm-dd"));
query_key["enddate"] = char(Format(cur_end,"yyyy-mm-dd"));
Save Text File("$temp/url_file"||char(index)||".txt",url);
Save Text File("$temp/query_keys_file"||char(index)||".txt",As JSON Expr(query_keys));
index++;
if(Date Increment(cur_start,"day",-day_inc)>start,
cur_start = Date Increment(cur_start,"day",-day_inc),
cur_start = start;
);
cur_end = Date Increment(cur_end,"day",-day_inc);
);
index--;
nscripts = index;
njmp = 1; //You can parallelize this as much as you want by launching more jmp instances. Or if you want to
// a place to keep up with running instances
rp = [=> ];
rpIndex=0;
For( i = 1, i <= njmp, i += 1,
// build a custom JSL for each JMP to execute
workerFileName = Save Text File(
"$temp\deleteMe_RunsWhenLaunchedBeCareful" || Char( i ) || ".jsl",
"\[//!
deletefile("$temp/sentinel.txt");
for(i=1,i<=]\"||char(nscripts)||"\[,i++,
if(Is File("$temp/url_file"||char(i)||".txt"),
url = Load Text File( "$temp/url_file"||char(i)||".txt" ) ;
query_key = Parse JSON( Load Text File( "$temp/query_keys_file"||char(i)||".txt" ) );
Delete File("$temp/url_file"||char(i)||".txt");
Delete File("$temp/query_keys_file"||char(i)||".txt");
//Using try so if one request fails I can keep moving through the requests
Try(
dig_http = New HTTP Request(URL(url),Method("Get"),Query String(query_key),Timeout(60*60*2))<<Send;
//My data is coming in as csv so I convert that to jmp.
file_name = "$temp/data"||char(i)||".csv";
Save Text File(file_name,dig_http);
dt = Open(file_name);
dt << Save("$temp/data"||char(i)||".jmp");
Delete File("$temp/data"||char(i)||".csv");
,
//Dummy file if try fails
dt = New Table();
dt << Save("$temp/data"||char(i)||".jmp");
);
);
);
exit();
]\"
);
// don't launch another copy until the previous copy is running.
// JMP will become unhappy if the preferences file is busy in another
// copy of JMP. The sentinel will be deleted when JMP starts
savetextfile("$temp/sentinel.txt","");
rp[rpIndex+=1] = Run Program( executable( "jmp" ), options( {workerFileName} ) );
write("\!n",i," started...");
// wait for the sentinel to vanish
while(fileexists("$temp/sentinel.txt"),
wait(1);// don't burn the CPU while waiting
);
write("ok");
);
// many queries are probably still queued, wait for them to finish
scripts_left = nscripts;
While( scripts_left,
scripts_left = 0;
For( i = 1, i <= nscripts, i++,
If(Is File("$temp/url_file"||char(i)||".txt"),
scripts_left += 1; // count the ones still alive
)
);
write("\!n",scripts_left," http requests left");
wait(1); // don't burn the CPU while waiting
);
Write( "\!ngathering results..." );
dt = New table("Final Table");
For( i = 1, i <= nscripts, i += 1,
filename="$temp/data"||char(i)||".jmp";
// do something with the results
// clean up the temp files
tmp_dt = open(filename);
dt << Concatenate(tmp_dt,Append to First Table);
Close(tmp_dt);
deletefile(filename);
deletefile("$temp\deleteMe_RunsWhenLaunchedBeCareful" || Char( i ) || ".jsl");
);
Write( "\!ndone" );