Hi @Reto ,
Modified your example slightly below. The data argument of requests.put() needs to be passed as a JSON string. I just used json.dumps() from the json library.
import requests
import json
class getData:
def __init__(self):
self.data = []
Auth_URL = "https://localhost/identity-manager/api/v2/auth/token"
ServerVar_URL = "https://localhost/automation/api/v2/nodes/" + "samples/kvd/implicit/xyz/g"
def makeVarables(user: str, pwd: str):
# Make the datalayer entries. Key Value database app must be installed!
# Authorisation
session = requests.Session()
session.verify = False
print(getData.ServerVar_URL)
response = session.post(getData.Auth_URL, json={"name": user, "password": pwd}).json()
token = response['access_token']
data_token = {"Authorization": f"Bearer {token}"}
payload = {
"type": "int32",
"value": 315
}
r = session.put(url=getData.ServerVar_URL, data=json.dumps(payload), headers=data_token)
print('Status Code=%s' % (r.status_code))
print(r.json())
test = getData
test.makeVarables('boschrexroth', 'boschrexroth')
exit(-1)
... View more