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 simulationGET https://httpbin.org/status/200HTTP 200[Asserts]duration < 1000
# Response time monitoringGET https://httpbin.org/delay/1HTTP 200[Asserts]duration >= 1000duration < 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 validationGET https://www.skybear.net/_live-demo/sample-001.jsonHTTP 200[Asserts]jsonpath "$.name" == "Alice"jsonpath "$.age" == 30jsonpath "$.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 dataPOST https://httpbin.org/postContent-Type: application/json{ "name": "New Product", "price": 19.99}HTTP 200[Captures]request_data: jsonpath "$.json"
# Read - GET request with parametersGET https://httpbin.org/get?product=123HTTP 200[Asserts]jsonpath "$.args.product" == "123"
# Update - PUT requestPUT https://httpbin.org/putContent-Type: application/json{ "name": "Updated Product", "price": 29.99}HTTP 200[Asserts]jsonpath "$.json.name" == "Updated Product"
# Delete - DELETE requestDELETE https://httpbin.org/deleteHTTP 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 PATCHPATCH https://httpbin.org/patchContent-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 structureGET https://www.skybear.net/_live-demo/sample-001.jsonHTTP 200[Asserts]jsonpath "$.address.zip" matches "^[0-9]{5}$"jsonpath "$.scores" count == 3jsonpath "$.projects[*].name" existsjsonpath "$.favorites.colors" count == 3jsonpath "$.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 < 1000body 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 schemaGET https://www.skybear.net/_live-demo/sample-001.jsonHTTP 200[Asserts]jsonpath "$.name" existsjsonpath "$.age" existsjsonpath "$.isStudent" existsjsonpath "$.scores" existsjsonpath "$.address" exists
Basic Authentication
Demonstrates how to authenticate API requests using HTTP Basic Authentication with encoded credentials.
# Basic auth exampleGET https://httpbin.org/basic-auth/username/passwordAuthorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=HTTP 200[Asserts]jsonpath "$.authenticated" == truejsonpath "$.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 parametersPOST https://httpbin.org/post[FormParams]name: John Doeemail: [email protected]message: Hello, this is a test messageHTTP 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.jsonHTTP 200
# Upload a filePOST https://httpbin.org/post[MultipartFormData]uploaded_file: file,sample.json;HTTP 200[Asserts]jsonpath "$.files" existsjsonpath "$.headers.Content-Type" contains "multipart/form-data"
HTTP Protocol Features
Demonstrates testing HTTP compression by requesting gzipped content and validating the response.
# Testing compressionGET https://httpbin.org/gzipAccept-Encoding: gzip, deflateHTTP 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 exampleGET https://httpbin.org/xmlAccept: application/xmlHTTP 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 requestGET https://httpbin.org/etag/testvalueHTTP 200[Captures]etag: header "ETag"
# Second request with If-None-Match headerGET https://httpbin.org/etag/testvalueIf-None-Match: {{etag}}HTTP 304
Cookie Operations
Illustrates how to set and verify cookies manually and across multiple requests in a testing session.
# Set a cookie manuallyGET https://httpbin.org/cookiesCookie: session=abc123HTTP 200[Asserts]jsonpath "$.cookies.session" == "abc123"
# Using cookies across requestsGET https://httpbin.org/cookies/set?session=xyz456[Options]location: trueHTTP 200
# Verify cookie was set by previous requestGET https://httpbin.org/cookiesHTTP 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 valueGET https://httpbin.org/uuidHTTP 200[Captures]request_id: jsonpath "$.uuid"
# Second request uses the captured valueGET https://httpbin.org/anythingContent-Type: application/jsonX-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 responseGET https://httpbin.org/status/404HTTP 404
# Testing 400 Bad Request responseGET https://httpbin.org/status/400HTTP 400
Delay Between Requests
Shows how to add intentional delays between requests to simulate realistic user behavior or respect rate limits.
# First requestGET https://httpbin.org/getHTTP 200
# Second request delayed by 2 seconds, and itself taking 1 second.GET https://httpbin.org/delay/1[Options]delay: 2sHTTP 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 headersGET https://httpbin.org/response-headers?X-RateLimit-Limit=100&X-RateLimit-Remaining=99&X-RateLimit-Reset=1616180060HTTP 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.
- Hurl Entry: A Hurl file is a list of entries, each entry being a mandatory request, optionally followed by a response.
- Hurl Request Structure: Structure of the request block for a Hurl entry.
- Hurl Response Structure: Structure of the response block for a Hurl entry.
- Hurl Response Capturing: Extract values from the HTTP responses in named variables.
- Hurl Response Asserting: All ways to test various properties of an HTTP response.
- Hurl Filters: Transform values in asserts and captures.