robotframework-requests-skill

Guide AI agents in creating REST API tests using RequestsLibrary. Use when building HTTP client tests, JSON/XML API testing, session management, authentication, file uploads, and response validation.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "robotframework-requests-skill" with this command: npx skills add manykarim/robotframework-agentskills/manykarim-robotframework-agentskills-robotframework-requests-skill

Requests Library Skill

Quick Reference

RequestsLibrary provides HTTP client keywords for REST API testing, wrapping Python's requests library. It supports JSON, XML, form data, file uploads, and all authentication methods.

Installation

pip install robotframework-requests

Library Import

*** Settings ***
Library    RequestsLibrary
Library    Collections    # Often needed for dict/list operations

Two Usage Styles

Style 1: Sessionless (Simple, Recommended for Most Cases)

Direct HTTP calls without session management:

${response}=    GET    https://api.example.com/users
${response}=    POST   https://api.example.com/users    json=${data}
${response}=    PUT    https://api.example.com/users/1  json=${data}
${response}=    DELETE https://api.example.com/users/1

Style 2: With Session (For Multiple Calls to Same API)

Create a session once, reuse for multiple requests:

Create Session    api    https://api.example.com    verify=${True}
${response}=    GET On Session    api    /users
${response}=    POST On Session   api    /users    json=${data}
${response}=    DELETE On Session    api    /users/1

Core Keywords Quick Reference

HTTP Methods

KeywordUsageDescription
GETGET ${URL}Retrieve resource
POSTPOST ${URL} json=${data}Create resource
PUTPUT ${URL} json=${data}Replace resource
PATCHPATCH ${URL} json=${data}Partial update
DELETEDELETE ${URL}Remove resource
HEADHEAD ${URL}Get headers only
OPTIONSOPTIONS ${URL}Get allowed methods

Request Options

OptionExampleDescription
jsonjson=${dict}Send JSON body
datadata=${form}Send form data
paramsparams=${query}URL query parameters
headersheaders=${headers}Custom headers
expected_statusexpected_status=201Verify status code
timeouttimeout=30Request timeout (seconds)
verifyverify=${False}SSL verification

Working with JSON

Send JSON Data

&{user}=    Create Dictionary    name=John    email=john@example.com
${response}=    POST    ${API_URL}/users    json=${user}

Parse JSON Response

${response}=    GET    ${API_URL}/users/1
${json}=    Set Variable    ${response.json()}
${name}=    Set Variable    ${json}[name]
${email}=   Set Variable    ${json}[email]

Access Nested JSON

# Response: {"user": {"profile": {"name": "John"}}}
${name}=    Set Variable    ${response.json()}[user][profile][name]

Response Validation

Status Code Verification

# In request (recommended)
${response}=    GET    ${URL}    expected_status=200
${response}=    POST   ${URL}    json=${data}    expected_status=201
${response}=    DELETE ${URL}    expected_status=204

# Post-request
Status Should Be    200    ${response}
Should Be Equal As Integers    ${response.status_code}    200

# Accept any status (for error testing)
${response}=    GET    ${URL}/notfound    expected_status=anything

Response Content Validation

Should Be Equal    ${response.json()}[status]    success
Should Contain     ${response.text}    success
Dictionary Should Contain Key    ${response.json()}    id
Should Not Be Empty    ${response.json()}[name]

Headers

Set Request Headers

&{headers}=    Create Dictionary
...    Authorization=Bearer ${TOKEN}
...    Content-Type=application/json
...    Accept=application/json
${response}=    GET    ${URL}    headers=${headers}

Check Response Headers

${content_type}=    Set Variable    ${response.headers}[Content-Type]
Should Contain    ${content_type}    application/json

Common Patterns

CRUD Operations

*** Test Cases ***
CRUD User Lifecycle
    # Create
    &{user}=    Create Dictionary    name=John    email=john@test.com
    ${response}=    POST    ${API}/users    json=${user}    expected_status=201
    ${user_id}=    Set Variable    ${response.json()}[id]

    # Read
    ${response}=    GET    ${API}/users/${user_id}    expected_status=200
    Should Be Equal    ${response.json()}[name]    John

    # Update
    &{updates}=    Create Dictionary    name=John Updated
    ${response}=    PUT    ${API}/users/${user_id}    json=${updates}    expected_status=200
    Should Be Equal    ${response.json()}[name]    John Updated

    # Delete
    ${response}=    DELETE    ${API}/users/${user_id}    expected_status=204

Authentication Patterns

# Bearer Token
&{headers}=    Create Dictionary    Authorization=Bearer ${TOKEN}
${response}=    GET    ${URL}    headers=${headers}

# Basic Auth (using auth parameter)
${auth}=    Create List    ${USERNAME}    ${PASSWORD}
${response}=    GET    ${URL}    auth=${auth}

Query Parameters

&{params}=    Create Dictionary    page=1    limit=10    sort=name
${response}=    GET    ${API}/users    params=${params}
# Results in: GET /users?page=1&limit=10&sort=name

Response Object Properties

PropertyDescriptionExample
status_codeHTTP status code${response.status_code}
textResponse body as text${response.text}
json()Parse JSON response${response.json()}
headersResponse headers dict${response.headers}[Content-Type]
contentResponse body as bytes${response.content}
cookiesResponse cookies${response.cookies}
elapsedRequest duration${response.elapsed.total_seconds()}

Request Should Be Successful

# Verifies the response status code is in the 2xx range
${response}=    GET    ${URL}/users
Request Should Be Successful    ${response}

Session Keywords

Specialized Session Types

# Client certificate authentication session
Create Client Cert Session    alias    ${URL}    client_certs=${CURDIR}/client.pem

# Digest authentication session
Create Digest Session    alias    ${URL}    auth=${auth}

# NTLM authentication session
Create Ntlm Session    alias    ${URL}    auth=${auth}

Security Warning

Create Session has verify=${False} by default -- SSL verification is OFF. For production environments, always explicitly enable SSL verification:

# INSECURE (default) -- do NOT use in production
Create Session    api    ${URL}

# SECURE -- explicitly enable SSL verification
Create Session    api    ${URL}    verify=${True}

When to Load Additional References

Load these reference files for specific use cases:

  • All HTTP methods and options -> references/http-methods.md
  • Request parameters, headers, SSL, proxies -> references/request-options.md
  • Response assertions -> references/response-validation.md
  • OAuth, JWT, API keys -> references/authentication.md
  • Full keyword listing -> references/keywords-reference.md
  • Error debugging -> references/troubleshooting.md

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

robotframework-appium-skill

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

robotframework-selenium-skill

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

robotframework-testcase-builder

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

robotframework-browser-skill

No summary provided by upstream source.

Repository SourceNeeds Review