# API Recipe: Process HAR Files

# **Overview**

LiveConnect allows you to validate the analytics and other tagging in your iOS or Android app. You can read about how to [upload HAR files to LiveConnect manually](https://help.observepoint.com/en/articles/9113452-downloading-uploading-har-files-web), and this guide will show you how to automate it with the ObservePoint API.

***Note:*** *You might not have access to LiveConnect with HAR File Upload. Reach out to your Customer Success Manager or Account Executive to verify if you have access.*

# **Getting Your HAR Files**

**HAR files** can be exported from various devices and applications. The easiest way is through the browser, as described [here for websites](https://help.observepoint.com/en/articles/9113452-downloading-uploading-har-files-web) and [here for mobile apps](https://help.observepoint.com/en/articles/9113445-downloading-uploading-har-files-mobile). You can also export them through [Charles Proxy](https://www.charlesproxy.com/) and some device farm tools including, but not limited to [SauceLabs](https://saucelabs.com/), [BrowserStack](https://www.browserstack.com/), and [BitBar](https://bitbar.com/).

# **Before You Begin**

You will need:

- LiveConnect with HAR Upload enabled on your ObservePoint account
- [Your ObservePoint API key](https://api-docs.observepoint.com/#authentication)
- The path on your computer where your HAR file is saved


# One-time Setup per Device

### Get your Device ID

Make a `GET` call to `https://api.observepoint.com/v2/manual-journeys` to return a list of all the devices for your account, and more importantly to obtain the `id` of the device.


```json The JSON response displaying the LiveConnect Journey id {manualJourneyId}
[
  {
    ...
    "id": 123,
    ...
  }
]
```

### Determine your ObservePoint User ID

Using your API key, do a GET request to this URL:

`GET https://api.observepoint.com/v2/users/current`

That will respond with JSON that contains your user ID, which you will need in step 2.


```Current user response data
{  
  ...  
  "id": 123,  
  ..  
}
```

# **Automate Uploading Your HAR Files**

Processing HAR files is a three-step process. Your code should execute these 3 steps every time you have HAR file(s) you are ready to process.

### **1**. Get Your Upload Credentials

This is not the same as your ObservePoint API key. These credentials allow you to upload HAR files to a file store, where ObservePoint will then process them.

*Note: These credentials expire after ~15 minutes, so your code should fetch new credentials every time you do a HAR upload.*

Make a request to `GET https://api.observepoint.com/v2/manual-journeys/{manualJourneyId}/har-runs/s3-post-policy`

This will respond with the credentials:


```json LiveConnect Journey Credentials
{  
    "objectKeyPrefix": "uploaded\_files/users/123/",  
    "uploadUrl": "https://prod-customer-uploads-bucket.s3.amazonaws.com/",  
    "formData": {  
        "X-Amz-Algorithm": "AWS4-HMAC-SHA256",  
        "tagging": "<Tagging>...</Tagging>",  
        "Policy": "eyA...fQ==",  
        "X-Amz-Signature": "5a3...c85",  
        "acl": "private",  
        "X-Amz-Date": "20250011T000000Z",  
        "X-Amz-Credential": "AKIA...est"  
    }  
}
```

You will need the following from the above response for next steps:

- `objectKeyPrefix`
- `uploadUrl`
- `formData`


### **2. Upload each HAR file**

Make a request to `POST https://api.observepoint.com/v2/manual-journeys/{deviceID}/har-runs` for each desired HAR file upload.

with the following request header:

`Content-Type: multipart/form-data`

and the following variables in the request's form-encoded payload ([learn how to send a form-encoded request payload](https://multipart/form-data))

***Tip:*** *Every programming language can send form-encoded POST requests. You can find instructions on how to do this in your language of choice online ([how to do this in Python](https://www.scrapingdog.com/blog/send-post-python-requests/)).*

- `X-Amz-Algorithm` = `AWS4-HMAC-SHA256`
- `tagging` = `{formData.tagging}`
- `policy` = `{formData.policy}`
- `acl` = `private`
- `X-Amz-Date` = `{formData.X-Amz-Date}`
- `key` = `uploaded_files/users/{userId}/{a name for your test}`
  - Tip: You can use the HAR file name, but make it unique from previous HAR uploads. You might consider using a UUID to ensure uniqueness.
  - Important: Your code will need to use this name in step 3, so store it in a variable (or an array if you have multiple HAR files)
- `X-Amz-Credential` = `{formData.X-Amz-Credential}`
- `file` = `@c:\Users\{path to har file}\your-har-file.json`
  - Important: The `@` symbol is required
  - Important: Replace the text to the right of `@` with the path to the HAR file on your computer)


### **3.** Start HAR Processing

Now that you've uploaded your HAR file(s), you can request ObservePoint to start processing the HAR file(s) by sending a request to:

`POST https://api.observepoint.com/v2/manual-journeys/{deviceID}/har-runs`

with the following header:

`Content-Type: application/json`

and the following request payload in JSON:


```json Start Har Processing Response
{  
  "journeyRunName": "{a name for your test, which appears in the UI}",  
  "harFiles": [  
    {  
      "s3Key": "uploaded\_files/users/{your user ID}/{the name}",  
      "name": "{name of your HAR file}"  
    },  
    ...  
    // more HAR files here if you have more than one  
  ]  
}
```

It is recommended to apply Data Validation Rules manually using the ObservePoint user interface as they will automatically apply for all subsequent runs.