Using REST API to run server based script file

I am wondering if the REST API can be used to load and run a script file hosted on the private instance?

I would like to be able to submit a request from an application of our and passing the script via a post is less than ideal (login info would need to be passed).

Thanks

No, it can’t pull pre-defined scripts (currently anyway).

Thanks, good to know. Maybe if I have time I’ll search the code see what is involved in do that (maybe hardcode path and just send filename to minimize security risk)

Shouldn’t be too hard. Somewhere around here: webpagetest/runtest.php at master · WPO-Foundation/webpagetest · GitHub

Add a new parameter that identifies pre-defined scripts (say “runscript”) and if that parameter is set go load the script into $test[‘script’]. It will get treated as if it was passed in from that point on (do it after $test[‘script’] is initially set or it will be overwritten). You need to be a bit careful about server attacks so don’t pass in the actual file name unless you do some regex scrubbing.

Another option (maybe cleaner) would be to define script replacement strings and in ValidateScript ( webpagetest/runtest.php at master · WPO-Foundation/webpagetest · GitHub ) you could do the string replacement like we do for the built-in %URL% and %HOST% placeholders.

Ahh cool. Thanks for the info, the cleaner is a good idea.