Skip to content

Improve Documentation for e.g. PYython example #113

@ilja-stas

Description

@ilja-stas

That was working for me. But I didn't know the option "cert" in requests.get etc.
Are more detailed docu would be good.

first following the postman instruction: https://github.com/BoschSmartHome/bosch-shc-api-docs/tree/master/postman

openssl req -x509 -nodes -days 9999 -newkey rsa:2048 -keyout python-key.pem -out python-cert.pem

import requests
import base64
import urllib3

# Suppress the InsecureRequestWarning related to verify=False
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# Variables (replace with actual values)
shc_api = "https://192.168.0.10:8444"  # Replace with your actual SHC API URL
api_version = "3.13"  # Replace with the actual API version you're using
system_password_base64 = base64.b64encode(b'testtest').decode('utf-8')  # Replace with your password

# Endpoint for devices
url = f"{shc_api}/smarthome/devices"  # Replace with the actual devices endpoint

# Path to client certificate and key files (replace with actual paths)
client_cert = ('/home/user/python-cert.pem', '/home/user/python-key.pem')  # Update these paths

# Headers
headers = {
    'Content-Type': 'application/json',
    'User-Agent': 'PostmanRuntime/7.42.0',
    'Accept': '*/*',
    'Accept-Encoding': 'gzip, deflate, br',
    'Connection': 'keep-alive',
    'Systempassword': system_password_base64,
    'api-version': api_version,
    'Host': '192.168.0.10:8444',
}

# No payload needed for GET request to /smarthome/devices

# Make the GET request with client certificate
response = requests.get(url, headers=headers, cert=client_cert, verify=False, timeout=120)

# Print the response
print(f"Status Code: {response.status_code}")
print(f"Response Body: {response.text}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions