cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Kepware Configuration API PUT command with response code = 401

PB_10095609
1-Newbie

Kepware Configuration API PUT command with response code = 401

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:

PB_10095609_0-1635329372810.png

 

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.

0 REPLIES 0
Top Tags