Running scripts with RESTful APIs

Hi,

I am using the RESTful APIs for automating tests. I found the documentation here https://sites.google.com/a/webpagetest.org/docs/advanced-features/webpagetest-restful-apis.

This works well when i have a single web page to run a test against. But i have the scenarios where i need to go to first page, e.g login fill in some values, and the run tests on a different page.

I have used the script feature from the webpagetest home page but i want to use the scripts with restful api. Going through the documentation i found the RESTful API allows script but i could not find any documentation for passing the script to the API.

Any help is appreciated.

The API has a “script” parameter (should be documented on the REST API docs page). If you are using HTTP GETs to talk to the API make sure to urlencode the script first.

Thanks Patrick for the quick reply. I tried running the test using Get as well as post. Here are some of issues I faced.

Using Get
I get a HTTP Status 200 back on the API response. With the ** returned I can see the test is executing. But finally the test fails. here is one the result.

Using Post
I am always getting the following error. The script has the navigate command and tab delimited. I am using the same script i use in the script tab in the home page.
I am using application/x-www-form-urlencoded for post. Seems I am missing something here.

400

Invalid Script (make sure there is at least one navigate command and that the commands are tab-delimited). Please contact us if you need help with your test script.

Check your script and encoding. Looking at the script that was used in the test, it has tabs followed by 3 spaces separating the commands and values.

what are the correct separation? I haven’t found nothing on it…
I’ve tried all spaces; spaces+tabs; spaces+tabs+newline; tabs+newline. All encoded and all failed (((

here is the simple script to test:
logData 0
navigate https://google.com
logData 1
navigate https://facebook.com

and one of the tried POST:
[i]POST WebPageTest

POST data:
label=testApi&location=ec2-eu-west-1%3AChrome%3ANative&runs=3&fvonly=0&script=logData+0+navigate+https%3A%2F%2Fgoogle.com+logData+1+navigate+https%3A%2F%2Ffacebook.com&video=1&k=…&tcpdump=1&mobile=1&tester=IP-AC1F1799&timeline=1&ignoreSSL=1

[no cookies]

Request Headers:
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 282
Host: www.webpagetest.org
Proxy-Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.3.1 (java 1.5)[/i]

And all I get is always - "Invalid Script (make sure there is at least one navigate command and that the commands are tab-delimited). Please contact us if you need help with your test script.
"

Correct separation is tabs. If you are sending it as POST data it needs to be mime-encoded form input, otherwise url-encoded as query params on the URL itself.

something like runtest.php?..&script=logData%090%0Anavigate%09https%3A%2F%2Fgoogle.com%0AlogData%091%0Anavigate%09https%3A%2F%2Ffacebook.com