Updating an IVR Config using a swagger class

Hello,

I am trying to update an IVR's config using body = PureCloudPlatformClientV2.IVR() and was wondering how include the json body using body = PureCloudPlatformClientV2.IVR(). I normally just create a JSON body but wanted to know how I could use this method.

Code snippet:

api_instance = PureCloudPlatformClientV2.ArchitectApi()
ivr_id = 'ivr_id_example' # str | IVR id
body = PureCloudPlatformClientV2.IVR() # IVR | 

try:
    # Update an IVR Config.
    api_response = api_instance.put_architect_ivr(ivr_id, body)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling PutArchitectIvrRequest->put_architect_ivr: %s\n" % e)

Thanks.

Hi Chris,

If you want to update an existing IVR, instantiating a variable with PureCloudPlatformClientV2.IVR() won't do, as you are creating a new IVR object. This would be more appropriate for a POST operation.
I believe what you should do is perform a GET request using the IVR ID and change fields on the response body which, if successful, will be the IVR config. I've attached an example below.

    try:
        body = architectApi.get_architect_ivr(ivrId)
        body.description = 'Updated description'
        try:
            api_response = architectApi.put_architect_ivr(ivrId, body)
            pprint(api_response)        
        except ApiException as e:
            print("Exception when calling PutArchitectIvrRequest->put_architect_ivr: %s\n" % e)
    except ApiException as e:
        print("Exception when calling GetArchitectIvrRequest->get_architect_ivr: %s\n" % e)

Please let me know if this answers your question.

Kind regards,
Charlie

1 Like

Thank you, I will give this a go, appreciate it.

Kind Regards,
Chris

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.