Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Dear Support Team,
I use your Configuration API to export and import Kepware configuration. On the export no problem. During import and an update of a property, I got the error code 401 from the PUT request:
reponse.json() = {'code': 401, 'message': 'The supplied user credentials are invalid or do not have permission to complete the requested action.'}
I use an administrator user who should have all the access to process the import:
This is my code to perform the PUT request:
# open a session
session = requests.session()
session.auth = (kep_user, kep_password) # ('Administrator', '**')
# session.headers.update({"content-type": "text"})
# http:// not working, use protocol https:// but don't verify certificate, seems to work
session.verify = False
adapter = requests.adapters.HTTPAdapter(max_retries=3)
session.mount('https://', adapter)
session.mount('http://', adapter)
# Send a GET to retrieve PROJECT_ID (response OK)
...
# Send a PUT to update a or more properties:
request = requests.Request('PUT', url)
preparerequest = request.prepare()
preparerequest.body = body
response = session.send(preparerequest)
Where url = "https://myservername:57512/config/v1/project/channels/Channel1"
body = {'common.ALLTYPES_DESCRIPTION': 'Example Simulator Channel UPD',
'PROJECT_ID': 1117018784,
'FORCE_UPDATE': 'true'}
I tried with and without FORCE_UPDATE, but response code is always 401.
Could you help me to find the root cause of the response 401? thanks.
Best regards,
Philippe Boxho.