i am trying to update user EXs through the API and the closest way i got is patch_user() in here but how i pass body parameter
body = PureCloudPlatformClientV2.UpdateUser() # UpdateUser | User
try:
# Update user
api_response = api_instance.patch_user(user_id, body)
pprint(api_response)
except ApiException as e:
print "Exception when calling UsersApi->patch_user: %s\n" % e
i tried python dictionary and that didn't work nor JSON
another important question is there an away to update the addresses part only instead of patching all user info and if so could you show me example code
what error are you getting? With a patch you should be able to update just the information you need to change by just passing that info into the request UpdateUser object
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Content-Length': '170', 'Connection': 'keep-alive', 'Date': 'Wed, 10 Oct 2018 23:21:56 GMT', 'inin-ratelimit-count': '52',
'inin-ratelimit-allowed': '180', 'inin-ratelimit-reset': '45', 'ININ-Correlation-Id': '0ba0b4b1-3dc8-43bc-b263-ac0df78100e4', 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 28f8194b09e7a5cef32fc3dbac5538f2.cloudfront.net (CloudFront)', 'X-Amz-Cf-Id': 'waE7E2udops2Pdqlk0r6fOX7oEMDrbhNQsUxo0EoOcDMOSKSyEwFhA=='})
HTTP response body: {"status":400,"code":"bad.request","message":"The requested operation failed with status 400","contextId":"0ba0b4b1-3dc8-43bc-b263-ac0df78100e4","details":[],"errors":[]} ```
`could you show me an example code how to update Name or one field
also how i create the user object ?`
When updating a user, you need to set the version to the current version of the user, so first you have to get the user config to find what that version is
import time
import PureCloudPlatformClientV2
from PureCloudPlatformClientV2.rest import ApiException
from pprint import pprint
PureCloudPlatformClientV2.configuration.access_token = 'AUTH TOKEN HERE'
# create an instance of the API class
api_instance = PureCloudPlatformClientV2.UsersApi()
user_id = 'f8ca529b-4fcb-4196-a34e-4ae6f7d1c974' # str | User ID
currentuser = api_instance.get_user(user_id)
body = PureCloudPlatformClientV2.UpdateUser() # UpdateUser | User
body.name = user_id
body.name = "New Name"
body.version = currentuser.version
try:
# Update user
api_response = api_instance.patch_user(user_id, body)
pprint(api_response)
except ApiException as e:
print "Exception when calling UsersApi->patch_user: %s\n" % e