Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Documentation for e.g. PYython example #113

Open
ilja-stas opened this issue Oct 16, 2024 · 0 comments
Open

Improve Documentation for e.g. PYython example #113

ilja-stas opened this issue Oct 16, 2024 · 0 comments

Comments

@ilja-stas
Copy link

ilja-stas commented Oct 16, 2024

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}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant