cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
633
Views
0
Helpful
16
Replies
Highlighted
Beginner

Changing agent state and code with API

Is there a way to change the state and reason code for a user using the REST API?

I have tried using the reasonCodeId and code tags to assign a nested in the user tag. No matter what I try making this call only changes the agent's state to NOT_READY without a reason code.

I have been able to change the state using:

URL : https://<adrres>:8445/finesse/api/User/<user id>

Type: GET

XML:

<User>

<state>NOT_READY</state>

</User>

Everyone's tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

Re: Changing agent state and code with API

Hi,

Yes, you need to use the API to change state with reason code: https://developer.cisco.com/media/finesseDevGuide4.1/CFIN_RF_C331CBFD_00_change-agent-state-with-reason.html


http://<FQDN>/finesse/api/User/<id>

<User>

  <state>NOT_READY</state>

  <reasonCodeId>10</reasonCodeId>

</User>


Thanx,

Denise

16 REPLIES 16
Cisco Employee

Re: Changing agent state and code with API

Hi,

Yes, you need to use the API to change state with reason code: https://developer.cisco.com/media/finesseDevGuide4.1/CFIN_RF_C331CBFD_00_change-agent-state-with-reason.html


http://<FQDN>/finesse/api/User/<id>

<User>

  <state>NOT_READY</state>

  <reasonCodeId>10</reasonCodeId>

</User>


Thanx,

Denise

Beginner

Re: Changing agent state and code with API

Thank you for the response!

I tried this tag and receive the following with a code 400.

<ApiErrors>

    <ApiError>

        <ErrorType>Invalid Input</ErrorType>

        <ErrorData>finesse.api.reasoncode.not_allowed</ErrorData>

        <ErrorMessage>For this operation, Reason Codes are not allowed.</ErrorMessage>

    </ApiError>

</ApiErrors>

Cisco Employee

Re: Changing agent state and code with API

Hi Brayden,

The error states that "Reason Codes are not allowed", do you have reason codes configured in Finesse? You can check by using the GET reason code list API.

Thanx,

Denise

Beginner

Re: Changing agent state and code with API

Yes, I do have codes setup for 'Not Ready'. When I run that query I get the following:

<ReasonCodes category="NOT_READY">

    <ReasonCode>

        <uri>/finesse/api/ReasonCode/1</uri>

        <category>NOT_READY</category>

        <code>1</code>

        <label>Break</label>

        <forAll>true</forAll>

    </ReasonCode>

    <ReasonCode>

        <uri>/finesse/api/ReasonCode/2</uri>

        <category>NOT_READY</category>

        <code>2</code>

        <label>Lunch</label>

        <forAll>true</forAll>

    </ReasonCode>

    <ReasonCode>

        <uri>/finesse/api/ReasonCode/3</uri>

        <category>NOT_READY</category>

        <code>3</code>

        <label>Project</label>

        <forAll>true</forAll>

    </ReasonCode>

    <ReasonCode>

        <uri>/finesse/api/ReasonCode/4</uri>

        <category>NOT_READY</category>

        <code>4</code>

        <label>Out of the Office</label>

        <forAll>true</forAll>

    </ReasonCode>

    <ReasonCode>

        <uri>/finesse/api/ReasonCode/5</uri>

        <category>NOT_READY</category>

        <code>5</code>

        <label>Busy</label>

        <forAll>true</forAll>

    </ReasonCode>

    <ReasonCode>

        <uri>/finesse/api/ReasonCode/10</uri>

        <category>NOT_READY</category>

        <code>6</code>

        <label>Meeting</label>

        <forAll>true</forAll>

    </ReasonCode>

    <ReasonCode>

        <uri>/finesse/api/ReasonCode/11</uri>

        <category>NOT_READY</category>

        <code>7</code>

        <label>Away</label>

        <forAll>true</forAll>

    </ReasonCode>

</ReasonCodes>

Using either the number assigned in <code> and the number in the <uri> both result in the same error in my last comment.

Cisco Employee

Re: Changing agent state and code with API

Hi Brayden,

Take a look at the Finesse webservices logs to see why you are getting this error. Based off of what you have provided above, I cannot give you a reason other than what the apiError says.

The reasonCodeId you need to use is the number found in the uri.

So, for the last one in the list above, it should be:

<User>

  <state>NOT_READY</state>

  <reasonCodeId>11</reasonCodeId>

</User>


Thanx,

Denise


Beginner

Re: Changing agent state and code with API

I ran that exact call that you listed above with no luck. It might be helpful to have the API provide a more verbose error as to what went wrong.

I'll check the logs and see if any additional information is provided.

A_ Beginner
Beginner

Re: Changing agent state and code with API

Did you find a solution for this? <reasonCodeId>[Id]</reasonCodeId> works with state LOGOUT but not with NOT_READY. I get the same error "For this operation, Reason Codes are not allowed."

Cisco Employee

Re: Changing agent state and code with API

Hi,

 

The same API (https://developer.cisco.com/docs/finesse/#!useragent-state-change-with-reason-code) should work for both LOGOUT and NOT_READY. Can you show me the URL and the body of your REST API request? Also, make sure that you actually have not ready reason codes configured on the system.

 

Thanx,

Denise

 

A_ Beginner
Beginner

Re: Changing agent state and code with API

Yes, I used this documentation.

 

For both I'm using HTTP-PUT. The reason code exists because if reason code doesn't exist then UCCX sending following error message (e.g. for reason code id "12321321321"):

 

<ErrorMessage>ReasonCode does not exist, codeId=12321321321</ErrorMessage>

So, for logout the content is (reason code 33 is only for test and it's a system reason code):

<User>
   <state>LOGOUT</state>
   <reasonCodeId>33</reasonCodeId>
</User>

The url is "https://[FQDN]:8445/finesse/api/User/[ExistingUserId]". This works perfectly.

But:

<User>
   <state>NOT_READY</state>
   <reasonCodeId>33</reasonCodeId>
</User>

This doesn't work. I get the error message for same URL:

 

 <ErrorMessage>For this operation, Reason Codes are not allowed.</ErrorMessage>

Thank you in advance!

Cisco Employee

Re: Changing agent state and code with API

Hi,

 

You cannot use system reason codes to change reason codes for agent state. It is only listed so that you know what code is already taken. Try to create your own reason code and use that value for testing. Remember that reason codes/ids are different for LOGOUT and NOT_READY.

 

Thanx,

Denise

A_ Beginner
Beginner

Re: Changing agent state and code with API

Just some hiccups for other ppl: The database id of reason code is not the reason code. You can get the database id with e. g.

https://[FINESSE]/finesse/api/Team/[teamId]/ReasonCodes?category=[category]

In the response you can see the database id. It's not the "code". This is not well documented in my opinion.

 

Nevertheless it doesn't work. I get the same error. "LOGOUT" works fine.

"NOT_READY" responses with:

<ApiErrors>
    <ApiError>
        <ErrorType>Invalid Input</ErrorType>
        <ErrorData>finesse.api.reasoncode.not_allowed</ErrorData>
        <ErrorMessage>For this operation, Reason Codes are not allowed.</ErrorMessage>
    </ApiError>
</ApiErrors>

Without " <reasonCodeId>[id]</reasonCodeId>" it works fine.

 

Do you have any other ideas?

 

Cisco Employee

Re: Changing agent state and code with API

Hi,

 

You need to use the reasonCodeId which you can find from <uri> tag of the output of the REST API you just listed.

 

 

<ReasonCodes category="NOT_READY">
    <ReasonCode>
        <uri>/finesse/api/ReasonCode/1</uri>
        <category>NOT_READY</category>
        <code>12</code>
        <label>Lunch</label>
        <forAll>True</forAll>
    </ReasonCode>
    <ReasonCode>
      ...Full ReasonCode Object...
   </ReasonCode>
    <ReasonCode>
      ...Full ReasonCode Object...
   </ReasonCode>
</ReasonCodes>

In this example, your <reasonCodeId> is 1.

 

If you are still having issues, can you share the output of the reason code list API that you posted?

 

Thanx,

Denise

 

 

 

A_ Beginner
Beginner

Re: Changing agent state and code with API

Result of GET-Request: https://[server]/finesse/api/Team/[id]/ReasonCodes?category=NOT_READY

<ReasonCodes category="NOT_READY">
    <ReasonCode>
        <uri>/finesse/api/ReasonCode/56</uri>
        <category>NOT_READY</category>
        <code>151</code>
        <label>Test reason</label>
        <forAll>false</forAll>
        <systemCode>false</systemCode>
        <active>true</active>
        <lastModified>1567679109</lastModified>
    </ReasonCode>
</ReasonCodes>

Then a PUT-Request to https://[server]/finesse/api/User/[userId] with xml content:

<User>
	<state>NOT_READY</state>
	<reasonCodeId>56</reasonCodeId>
</User>

I get the response:

<ApiErrors>
    <ApiError>
        <ErrorType>Invalid Input</ErrorType>
        <ErrorData>finesse.api.reasoncode.not_allowed</ErrorData>
        <ErrorMessage>For this operation, Reason Codes are not allowed.</ErrorMessage>
    </ApiError>
</ApiErrors>
Cisco Employee

Re: Changing agent state and code with API

Are you sure that the user is part of that particular team?

 

You can get that particular user's list of reason code using this API: https://developer.cisco.com/docs/finesse/#!userget-reason-code-list

http://<FQDN>/finesse/api/User/<id>/ReasonCodes?category=NOT_READY|LOGOUT

 

If the user is part of that team and that reason code shows up using the above API, then I'd need to look into the logs on why you are getting that error. You would need to open a ticket here: https://developer.cisco.com/site/support/

 

Thanx,

Denise

CreatePlease to create content
Content for Community-Ad
August's Community Spotlight Awards