Skip to content

Skybear.NET Examples

A collection of practical examples of Skybear.NET Hurl scripts for common HTTP API testing scenarios. Use these examples as templates for your own scripts.

Health Check Monitoring

Demonstrates how to implement health checks and response time monitoring with duration assertions.

# Health check simulation
GET https://httpbin.org/status/200
HTTP 200
[Asserts]
duration < 1000
# Response time monitoring
GET https://httpbin.org/delay/1
HTTP 200
[Asserts]
duration >= 1000
duration < 3000

Basic GET with JSON response assertion

Demonstrates how to make a simple GET request and validate the JSON response data with multiple assertions.

# Simple GET request with response validation
GET https://www.skybear.net/_live-demo/sample-001.json
HTTP 200
[Asserts]
jsonpath "$.name" == "Alice"
jsonpath "$.age" == 30
jsonpath "$.scores" count == 3

CRUD Operations

Illustrates a complete set of Create, Read, Update, and Delete operations using different HTTP methods against a JSON REST API.

# Create - POST request with data
POST https://httpbin.org/post
Content-Type: application/json
{
"name": "New Product",
"price": 19.99
}
HTTP 200
[Captures]
request_data: jsonpath "$.json"
# Read - GET request with parameters
GET https://httpbin.org/get?product=123
HTTP 200
[Asserts]
jsonpath "$.args.product" == "123"
# Update - PUT request
PUT https://httpbin.org/put
Content-Type: application/json
{
"name": "Updated Product",
"price": 29.99
}
HTTP 200
[Asserts]
jsonpath "$.json.name" == "Updated Product"
# Delete - DELETE request
DELETE https://httpbin.org/delete
HTTP 200
[Asserts]
jsonpath "$.url" == "https://httpbin.org/delete"

Partial Updates with PATCH

Shows how to perform partial resource updates using the HTTP PATCH method with a JSON payload.

# Partial update with PATCH
PATCH https://httpbin.org/patch
Content-Type: application/json
{
"name": "Updated Name"
}
HTTP 200
[Asserts]
jsonpath "$.json.name" == "Updated Name"

Complex JSON Assertions

Illustrates advanced JSON validation techniques including regex pattern matching, array counts, and filtering with JSONPath expressions.

# Validating nested JSON structure
GET https://www.skybear.net/_live-demo/sample-001.json
HTTP 200
[Asserts]
jsonpath "$.address.zip" matches "^[0-9]{5}$"
jsonpath "$.scores" count == 3
jsonpath "$.projects[*].name" exists
jsonpath "$.favorites.colors" count == 3
jsonpath "$.projects[?(@.status == 'completed')]" count == 1
# Assert multiple things on the response.
header "content-type" endsWith "/json"
# Assert the body as raw bytes or plain text!
bytes count < 1000
body contains "Maple"

JSON Schema Validation

Shows how to perform basic JSON schema validation by checking for the existence of required fields in the response.

# Validating response against JSON schema
GET https://www.skybear.net/_live-demo/sample-001.json
HTTP 200
[Asserts]
jsonpath "$.name" exists
jsonpath "$.age" exists
jsonpath "$.isStudent" exists
jsonpath "$.scores" exists
jsonpath "$.address" exists

Basic Authentication

Demonstrates how to authenticate API requests using HTTP Basic Authentication with encoded credentials.

# Basic auth example
GET https://httpbin.org/basic-auth/username/password
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
HTTP 200
[Asserts]
jsonpath "$.authenticated" == true
jsonpath "$.user" == "username"

Form Submission

Shows how to submit form data using HTTP POST with form parameters for typical web form interactions.

# Form submission with form parameters
POST https://httpbin.org/post
[FormParams]
name: John Doe
message: Hello, this is a test message
HTTP 200
[Asserts]
jsonpath "$.form.name" == "John Doe"
jsonpath "$.form.email" == "[email protected]"
jsonpath "$.form.message" == "Hello, this is a test message"

File Upload

Illustrates how to download a sample file and then upload it using multipart form data in a subsequent request.

# Download a sample file to use for the upload below.
GET https://www.skybear.net/_live-demo/sample-001.json
[Options]
output: sample.json
HTTP 200
# Upload a file
POST https://httpbin.org/post
[MultipartFormData]
uploaded_file: file,sample.json;
HTTP 200
[Asserts]
jsonpath "$.files" exists
jsonpath "$.headers.Content-Type" contains "multipart/form-data"

HTTP Protocol Features

Demonstrates testing HTTP compression by requesting gzipped content and validating the response.

# Testing compression
GET https://httpbin.org/gzip
Accept-Encoding: gzip, deflate
HTTP 200
[Asserts]
jsonpath "$.gzipped" == true

Content Negotiation

Shows how to request specific content types using the Accept header and validate the server’s response.

# Content negotiation example
GET https://httpbin.org/xml
Accept: application/xml
HTTP 200
[Asserts]
header "Content-Type" == "application/xml"
xpath "string(//slideshow/slide[1]/title)" == "Wake up to WonderWidgets!"

HTTP Caching

Demonstrates HTTP caching behavior by capturing an ETag value and using it in a subsequent request to trigger a 304 Not Modified response.

# Testing HTTP caching - First request
GET https://httpbin.org/etag/testvalue
HTTP 200
[Captures]
etag: header "ETag"
# Second request with If-None-Match header
GET https://httpbin.org/etag/testvalue
If-None-Match: {{etag}}
HTTP 304

Illustrates how to set and verify cookies manually and across multiple requests in a testing session.

# Set a cookie manually
GET https://httpbin.org/cookies
Cookie: session=abc123
HTTP 200
[Asserts]
jsonpath "$.cookies.session" == "abc123"
# Using cookies across requests
GET https://httpbin.org/cookies/set?session=xyz456
[Options]
location: true
HTTP 200
# Verify cookie was set by previous request
GET https://httpbin.org/cookies
HTTP 200
[Asserts]
jsonpath "$.cookies.session" == "xyz456"

Chaining Requests with Variables

Shows how to capture data from one request and use it as a variable in subsequent requests for dynamic testing scenarios.

# First request captures a value
GET https://httpbin.org/uuid
HTTP 200
[Captures]
request_id: jsonpath "$.uuid"
# Second request uses the captured value
GET https://httpbin.org/anything
Content-Type: application/json
X-Skybear-ID: {{ request_id }}
HTTP 200
[Asserts]
jsonpath "$.headers.X-Skybear-Id" == "{{ request_id }}"

Testing Error Responses

Demonstrates how to validate different HTTP error status codes including 404 Not Found and 400 Bad Request.

# Testing 404 response
GET https://httpbin.org/status/404
HTTP 404
# Testing 400 Bad Request response
GET https://httpbin.org/status/400
HTTP 400

Delay Between Requests

Shows how to add intentional delays between requests to simulate realistic user behavior or respect rate limits.

# First request
GET https://httpbin.org/get
HTTP 200
# Second request delayed by 2 seconds, and itself taking 1 second.
GET https://httpbin.org/delay/1
[Options]
delay: 2s
HTTP 200
[Asserts]
duration >= 1000

API Rate Limiting

Demonstrates how to test API rate limiting by verifying the presence and values of rate limit headers.

# Testing custom headers
GET https://httpbin.org/response-headers?X-RateLimit-Limit=100&X-RateLimit-Remaining=99&X-RateLimit-Reset=1616180060
HTTP 200
[Asserts]
header "X-RateLimit-Limit" == "100"
header "X-RateLimit-Remaining" == "99"
header "X-RateLimit-Reset" == "1616180060"

References

Checkout Hurl’s entire feature set at the Hurl.dev documentation.