Open topic with navigation

# Scripts

## Description

Uploads or retrieves a VuGen or JMeter script to/from LoadRunner Enterprise (in versions 2020 or later) or ALM (in versions 12.6x or earlier).

## URL

    /LoadTest/rest/domains/{domainName}/projects/{projectName}/Scripts

## Remarks

None

## HTTP Method

POST: Uploads a VuGen or JMeter script to LoadRunner Enterprise or ALM.

GET: Returns the script in the body of the response.

## Request

Headers:

Content-Type: multipart/form-data

Cookies:

Version 2020 (or later) | LWSSO_COOKIE_KEY={LwssoCookie};
Versions earlier than 2020 | LWSSO_COOKIE_KEY={LwssoCookie};QCSession={QCSessionCookie};

Request Body:

POST: Multipart data with two entities:

- A zipped VuGen or JMeter script.
- An XML describing the uploaded script.

GET: No request body

Request Example - POST

    POST http://<LRE_Server>/LoadTest/rest/domains/alex-qc/projects/demo_project/Scripts
    Content-Type: multipart/form-data; boundary="d8a33232-f54d-4fa6-a888-0b6b34810dfc"
    Content-Length: <content length>
    Expect: 100-continue
    --d8a33232-f54d-4fa6-a888-0b6b34810dfc
    Content-Disposition: form-data; name=metadata

    <Script xmlns="http://www.hp.com/PC/REST/API">
         <TestFolderPath>path to upload the script to LRE/ALM</TestFolderPath>
         <Overwrite>true</Overwrite>
         <RuntimeOnly>false</RuntimeOnly>
         <KeepCheckedOut>false</KeepCheckedOut>
     </Script>

    --d8a33232-f54d-4fa6-a888-0b6b34810dfc
    Content-Disposition: form-data; filename=ScriptWithVuserLog.zip
    Content-Type: application/x-zip-compressed
    <Content of the compressed script>
    --d8a33232-f54d-4fa6-a888-0b6b34810dfc--

Note: The value of the element boundary which marks the start and the end of the elements in HTTP multipart/form-data request is a value that can be changed based on the library being used (`d8a33232-f54d-4fa6-a888-0b6b34810dfc` is an example of a boundary value).

Request Example - GET

    GET http://<LRE_Server>/LoadTest/rest/domains/alex-qc/projects/demo_project/Scripts

The fields in the response are:

Element | Description
--- | ---
Script | The top-level element.
TestFolderPath | The path of the folder within the Test Plan where the script will be uploaded.
Overwrite | Action if script with the same pathname already exists. One of: true: Overwrite existing script. (default) false: Automatically rename new script.
RuntimeOnly | One of: true: Upload only runtime files. (default) false: Upload all files.
KeepCheckedOut | Applies if project supports versioning to indicate whether the script needs to be checked in/out after an upload. Use one of: true: Uploaded script will remain checked-out. false: Uploaded script is checked in. (default). Note: If the project does not support version control, this element is meaningless and you can leave the default value ("false") or not use the `KeepCheckedOut` element at all. Do not send an empty element.

## Response

Headers:

Content-Type: application/xml

Cookies:

None

HTML Return Code:

One of the HTTP Return Codes

HTML Body:

GET: Returns the data on the entity in the response. See Script XML

## See Also

Scripts/{ID}
Script XML