# 📜 Script and HTTP Activities

> **Parent page:** PAW Robot/Studio › Activities **Module:** PAWRobot.Script, PAWRobot (core) **Scope:** Code execution, HTTP requests, JSON


---

## Overview

Script and HTTP activities are used in PAW Robot/Studio to run custom code, communicate with external services and process data in JSON format.

* **Script Activities:** Run custom code in supported languages such as C#, VB, PowerShell and Python.
* **HTTP Activities:** Send requests to REST API services and receive the responses.
* **JSON Activities:** Convert objects to JSON format and transfer JSON data into objects or supported data structures.

Used together, these activities let you retrieve data from external systems, transform it and include it in automation processes.


---

## Script Activities

| Activity | Description |
|----------|-------------|
| [**Invoke Code**](/doc/invoke-code-6efpvybTBc) | Runs code in C#, VB, PowerShell or Python |

### Using InvokeCode

The `InvokeCode` activity is used to perform custom operations that cannot be done directly with standard activities by writing code.


1. Add the `InvokeCode` activity to the workflow.
2. Open the activity's code editor.
3. Select a supported programming language and write your code.
4. If needed, define the activity's arguments to use workflow variables in the code.
5. Pass the results produced by the code to the workflow through the appropriate output arguments.
6. Run the workflow and check the result and any errors.

**Usage recommendation:** Prefer standard activities for simple data operations. Use `InvokeCode` for complex transformations, custom calculations or operations that require several code steps.

 ![Code Editor Window](https://outline-production-attachments.s3-accelerate.amazonaws.com/uploads/16a71ae5-139a-40ac-a944-e134297802cb/9e930d02-77bf-4217-b87c-e69058d82b99/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA4EOUDTOVUICLPZ4P%2F20261123%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20261123T231500Z&X-Amz-Expires=86400&X-Amz-Signature=16fbe9e6b0959ba5c836c123216c535fe072bba4b1d93dd8f43a056c1d89f4f4&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject "left-50 =500x283")

> 💡 **Tip:** Use InvokeCode for complex data transformations and custom logic; prefer visual activities for simple operations.


---

## HTTP and Network Activities

| Activity | Description |
|----------|-------------|
| [**HTTP Request Creator**](/doc/http-request-creator-c5Jht504R4) | Creates an HTTP request (GET, POST, PUT, DELETE, etc.) |

Typical use: REST API call → JSON response → DeserializeJson → DataTable processing.

### Using HTTP Request Creator

The HTTP Request Creator activity is used to communicate with external services over the HTTP protocol.

When configuring the request, the following information is set according to the fields the activity supports:

* **Request address (URL):** The address of the service to call.
* **HTTP method:** A method such as GET, POST, PUT or DELETE, depending on what the service requires.
* **Headers:** Additional request information such as authentication details or content type.
* **Request body:** The data sent to the service with methods such as POST and PUT.
* **Response:** The status code and content returned by the service.

After the request completes, the returned response should be checked; successful results should be processed and error cases handled as the process requires.

**Warning:** Sensitive information such as API keys and access tokens should not be written directly into code; appropriate secure storage methods should be used.


---

## JSON Activities (Core)

| Activity | Description |
|----------|-------------|
| [**Serialize Json**](/doc/serialize-json-3na8jwigAV) | Converts an object to a JSON string |
| [**Deserialize Json**](/doc/deserialize-json-z0qQsSsMgA) | Converts a JSON string to an object or DataTable |

### JSON Serialization and Deserialization

**Serialize Json:** Converts an object to JSON text so that it can be used in operations such as API requests.

**Deserialize Json:** Converts text in JSON format into a supported object or data structure so that it can be processed.

Example usage flow:


1. Send a request to the API with the HTTP Request Creator activity.
2. Convert the returned JSON response into a suitable data structure with the Deserialize Json activity.
3. Process the resulting data with the relevant activities.
4. If needed, convert the processed data back to JSON format with the Serialize Json activity.


---

## Example Scenario: Retrieving Order Data via API

The following flow can be used to retrieve order data from an e-commerce service and process it in an automation process:


1. **HTTP Request Creator:** A GET request is sent to the order service.
2. **Response check:** Whether the request succeeded is checked.
3. **Deserialize Json:** The JSON response returned by the service is converted into a suitable data structure.
4. **Data processing:** The retrieved records are evaluated with loop or data processing activities.
5. **Error handling:** Connection errors, failed HTTP status codes and unexpected responses are handled.

Note: The JSON conversion format and data processing method to use should be determined by the structure of the API response and the data types supported by PAW activities.