Skip to main content
All CollectionsHAR Upload & LiveConnect
Automate HAR File Processing via the ObservePoint API
Automate HAR File Processing via the ObservePoint API
Luiza Gircoveanu avatar
Written by Luiza Gircoveanu
Updated yesterday

Overview

LiveConnect allows you to validate your iOS or Android app's analytics and other tagging. You can read about how to upload HAR files to LiveConnect manually, 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. Most easily is done through the browser, as described here for websites and here for mobile apps. You can also export them through Charles Proxy and some device farm tools including, but not limited to SauceLabs, BrowserStack, and BitBar.

Before You Begin

You will need:

  • LiveConnect with HAR Upload activated on your ObservePoint account

  • Your ObservePoint API key

  • The path on your computer where your HAR file is saved

One-time Setup per Device

Determine your Device ID

Log in to ObservePoint and goto LiveConnect. Create a device and take note of the device ID (159 in this example)

Set Up Validation Rules

In the LiveConnect UI, you can set up validation rules that ObservePoint will check every time you process a HAR file. This way, you can automatically be alerted if your test session produced missing or incorrect tags and variables.

Determine your ObservePoint User ID

Using your API key, do a GET request to this URL (how to send your API key):

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

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

{
...
"id": 123,
..
}

Automate Uploading Your HAR Files

Processing HAR file(s) is a 3-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, which you already have. 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 (which only takes a few seconds, so there's no need to worry about your credentials expiring).

Send a GET request to the following endpoint, authenticated with your ObservePoint API key (how to send your API key):

https://api.observepoint.com/v2/manual-journeys/{your deviceID goes here}/har-runs/s3-post-policy

This will respond with a JSON document containing the credentials you'll need in the next step, like this:

{
"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": "20250131T000000Z",
"X-Amz-Credential": "AKIA...est"
}
}

Your code should read the following values from the JSON response, which it will use in the next step

  • objectKeyPrefix

  • uploadUrl

  • formData

2. Upload each HAR file

For each HAR file you want to upload for this device, send a POST request to the following URL:

https://api.observepoint.com/v2/manual-journeys/{your deviceID goes here}/har-runs 

with the following request headers:

  • 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)

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).

  • X-Amz-Algorithm = AWS4-HMAC-SHA256

  • tagging = (the value from formDatatagging in step 1)

  • policy = (the value from formDatapolicy in step 1)

  • acl = private

  • X-Amz-Date = (the value from formDataX-Amz-Date in step 1)

  • key = uploaded_files/users/{your user ID}/{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 = (the value from formData --> X-Amz-Credential from step 1)

  • file = @c:\Users\example\your-har-file.json

    • Important: the @ 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), tell ObservePoint to start processing the HAR file(s) by sending a single POST request to:

https://api.observepoint.com/v2/manual-journeys/{your deviceID goes here}/har-runs 

with the following header:

  • Content-Type = application/json

and the following request payload in JSON:

{
"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 1
]
}

We recommend applying Data Validation Rules manually using the user interface as they will automatically apply for all subsequent runs.

Done!

Now that you uploaded your HAR files and told ObservePoint to start processing them, your test run will appear in LiveConnect under the device you specified. When it's finished, it will show a pass/fail indicator for your rules, and send an email to the configured recipients.

Appendix

cURL Example for Reference

The following concrete example shows how to use curl to process a HAR file.

# Step 1
curl --location --request GET 'https://api.observepoint.com/v2/manual-journeys/159/har-runs/s3-post-policy' \
--header 'Content-Type: application/json' \
--header 'Authorization: api_key {Your ObservePoint API Key}'

# Step 2
curl --location --request POST 'https://prod-customer-uploads-bucket.s3.amazonaws.com' \
--header 'Content-Type: multipart/form-data' \
--form 'X-Amz-Algorithm="AWS4-HMAC-SHA256"' \
--form 'tagging="<Tagging><TagSet><Tag><Key>orphaned_expire_after0</Key><Value>1_day</Value></Tag></TagSet></Tagging>"' \
--form 'Policy="{take from response to step 1}"' \
--form 'acl="private"' \
--form 'X-Amz-Date="{take from response to step 1}"' \
--form 'key="uploaded_files/users/{your user ID}/{choose a test name}"' \
--form 'X-Amz-Credential="{take from response to step 1}""' \
--form 'file=@"{the local path and name of your HAR file}"'

# Step 3
curl --location --request POST 'https://api.observepoint.com/v2/manual-journeys/{your deviceID goes here}/har-runs' \
--header 'Content-Type: application/json' \
--header 'Authorization: api_key {Your ObservePoint API Key}' \
--data-raw '{
"journeyRunName": "{a name for your test}",
"harFiles": [
{
"s3Key": "uploaded_files/users/{your user ID}/{test name from step 2}",
"name": {name of your HAR file}
}
]
}'
Did this answer your question?