Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
New Member

Modify Resource through company website (http://<server>/adminapi/resources/{id})

Hi everybody,

I have a question regarding changing agent skills automatically every night.

I've been told that it's possible to change agent skills back to "default" by using :

(found in Cisco-uccx-developer-guide-902.pdf)

Modify Resource



URI

http://<server>/adminapi/resources/{id}

Example URI

http://<server>/adminapi/resources/{id}

HTTP Method

PUT

Content Type

Application/XML, Application/JSON

HTTP Success Code

200

HTTP Failure Codes

401, 402, 405

Failure Response

-

Error Codes

-

But when I try I keep getting error 405 (Method not allowed) when using this script :

        Try

            Dim strHTTP = Request.ServerVariables("HTTP_HOST")

            Dim strServerFile As String = strHTTP & "/Webpage/Cisco_files/XML_masterfile.xml"

            Dim wc As WebClient = New WebClient

            wc.Credentials = New System.Net.NetworkCredential(usernameGoesHere, passwordGoesHer)

            wc.UploadString("http://10.146.102.13:8080/adminapi/resource/", "PUT", strServerFile)

        Catch ex As Exception

            Response.Write(ex)

        End Try

Can anybody tell me what I'm doing wrong?

See attached XML file for file details

32 REPLIES

Modify Resource through company website (http://<server>/adminap

Hi,

is there any other error message apart from the HTTP status?

Also, did you try looking at the logs? Start up RTMT and look for one named catalina.out.

G.

New Member

Modify Resource through company website (http://<server>/adminap

The problem is that I'm placed in an external company that are using the system, but we dont administrate it from here - so I'm not sure that I have access to those logs. What is the RTMT?

The error I get is in danish :

System.Net.WebException: Fjernserveren returnerede en fejl: (405) Metoden er ikke tilladt.    ved System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request)    ved System.Net.WebClient.UploadString(Uri address, String method, String data)    ved System.Net.WebClient.UploadString(String address, String method, String data)    ved _CiscoChange.UpdateAgentSkills() i E:\Projects\Webpage\CiscoChange.aspx.vb:linje 17

Fjernserveren returnerede en fejl: (405) Metoden er ikke tilladt = Remoteserver returned an error : (405) Method is not allowed

Is it possible to do from a SQL storedprocedure instead you think?

Modify Resource through company website (http://<server>/adminap

Hi,

no, SQL is not an option for administering UCCX. The REST API has been created to do that.

I'll try and install a UCCX 9 in my lab as soon as I find the installation media.

RTMT = RealTime Monitoring Tool, a software to download and analyze logs from UCCX.

G.

New Member

Modify Resource through company website (http://<server>/adminap

Real Time Monitoring Tool? I've got access to that ... I'll be right back!

New Member

Modify Resource through company website (http://<server>/adminap

Hi again Gergely,

I can't find the file i RTMT and I don't have access to root/ where it's also placed

Would be great if you are able to install and help me - thanks

Modify Resource through company website (http://<server>/adminap

Hi,

it's available on the UCCX. Tools > Pugins.

Once installed, go to the Trace & Log Central, Collect Files, select all files for both UCCX and System, then do the REST API test again, then download the recent logs. We are looking for one named catalina.out.

G.

New Member

Modify Resource through company website (http://<server>/adminap

I still cant find the file, all I get is this :

Collect Files in progress for node telm98cucm01.dk.telmore.net

Downloading results into E:\\TraceCollectionResult_2013-12-17_12-46-59_telm98cucm01.dk.telmore.net.xml for node telm98cucm01.dk.telmore.net

Completed downloading results into ...E:\\TraceCollectionResult_2013-12-17_12-46-59_telm98cucm01.dk.telmore.net.xml for node telm98cucm01.dk.telmore.net

Downloading files for node telm98cucm01.dk.telmore.net

Downloaded cdr_StandAloneCluster_02_201312171142_57043 from the node: telm98cucm01.dk.telmore.net

Downloaded cdr_StandAloneCluster_01_201312171142_84793 from the node: telm98cucm01.dk.telmore.net

Downloaded cdr_StandAloneCluster_02_201312171143_57044 from the node: telm98cucm01.dk.telmore.net

Downloaded cdr_StandAloneCluster_01_201312171143_84794 from the node: telm98cucm01.dk.telmore.net

Downloaded cdr_StandAloneCluster_02_201312171144_57045 from the node: telm98cucm01.dk.telmore.net

Downloaded cdr_StandAloneCluster_01_201312171144_84795 from the node: telm98cucm01.dk.telmore.net

Downloaded cdr_StandAloneCluster_02_201312171145_57046 from the node: telm98cucm01.dk.telmore.net

Downloaded cdr_StandAloneCluster_01_201312171145_84796 from the node: telm98cucm01.dk.telmore.net

Downloaded cdr_StandAloneCluster_02_201312171146_57047 from the node: telm98cucm01.dk.telmore.net

**********Collection Summary**********

HostName: telm98cucm01.dk.telmore.net

No.of files Collected: 9

Collection Failed for: 1 files.

The following files were not collected:

cdr_StandAloneCluster_01_201312171146_84797

*******************************************

Completed downloading for node telm98cucm01.dk.telmore.net

Modify Resource through company website (http://<server>/adminap

Hi,

er... you are downloding CDR files from a CUCM.

I might need to take a look at the log files from a UCCX.

G.

New Member

Modify Resource through company website (http://<server>/adminap

I'm getting this error, but that might be because it's server 2 - we also have one called telm98cucm01

Modify Resource through company website (http://<server>/adminap

Okay, this is another CUCM server.

Can you tell me the address of your UCCX server?

G.

New Member

Re: Modify Resource through company website (http://<server>/adm

I just got a lot more files this time around and I can see that we got catalina.out also

UCCX is called https://10.146.102.12 - but when I called that yesterday it failed collecting Ressources ... today it works

Re: Modify Resource through company website (http://<server>/adm

Hi,

I ran through that log quickly, but I can't see anything in detail.

Anyway, what is 10.146.102.13?

G.

Re: Modify Resource through company website (http://<server>/adm

One more thing, the doc says you need to pass the user ID (~ agent ID, or in CUCM: End User) in the URL

So you'll have to modify this line of your script:

wc.UploadString("

http://10.146.102.13:8080/adminapi/resource/

", "PUT", strServerFile)

to

wc.UploadString("

http://10.146.102.13:8080/adminapi/resource/johndoe

", "PUT", strServerFile)

G.

New Member

Re: Modify Resource through company website (http://<server>/adm

10.146.102.13 is Cisco Unified Intelligence Center

Ahh ... I thought I could update all agents in one run.

No I get error (415) Unsupported Media Type - I'll see if I can geet a new catalina file

New Member

Re: Modify Resource through company website (http://<server>/adm

Strange, I cant seem to generate a new catalina file now.

415 Unsupported Media Type

The media type specified in the Accept header is not supported by the  server. This will be the common response when the client resources  version is no longer supported by the server.

http://www.cisco.com/en/US/docs/security/ise/1.2/api_ref_guide/ise_api_ref_ers1.html

I really appriciate you help so far G - hope you still can help me.

New Member

Re: Modify Resource through company website (http://<server>/adm

And there I got a new catalina file (think it hasd something to do with the username I use for login)

But here it is

Re: Modify Resource through company website (http://<server>/adm

Hm.

I am not a .NET user and I'll never be, but there should be a way to specify the media type of your request. Should be set to "Application/XML".

About the security stuff: it's HTTP Basic, and the user should have administrative rights on UCCX.

Do you have curl? If not, please go and download it. We are going to try to invoke the UCCX REST API with it (just to eliminate the possibility of errors in your program).

G.

New Member

Re: Modify Resource through company website (http://<server>/adm

Hi G.

I've tried to download curl, but I can't seem to install it - it just blinks and then nothing happens.

This is my new script:

                Dim strServerFile As String = Server.MapPath("~/Cisco_files/XML_masterfile_Rarja.xml")

                Dim myWebClient As WebClient = New WebClient

                Dim strContentLenght As String = Encoding.ASCII.GetBytes(strServerFile).ToString

                myWebClient.Credentials = New System.Net.NetworkCredential("rarja", "myPasswordHere")

                myWebClient.Headers.Add("ContentLength", strContentLenght)

                myWebClient.Headers.Add("Content-Type", "Application/XML")

                myWebClient.UploadString("http://10.146.102.12:8080/adminapi/resource/rarja/", "PUT", strServerFile)

Now I get a (400) Bad Request when I run it - so I guess that we have progress

New Member

Re: Modify Resource through company website (http://<server>/adm

Hi G.

This is my new catalina from about now .. the one that have error 400

Re: Modify Resource through company website (http://<server>/adm

Okay, it is really necessary to bypass the program and just test the URL.

I don't understand this code, but are you sure the username/password combination is sent along with the HTTP request?

G.

New Member

Re: Modify Resource through company website (http://<server>/adm

If I remove it, I'm asked to type it in.

I'm still trying to get curl to install/work

New Member

Re: Modify Resource through company website (http://<server>/adm

Now I think Curl is installed according to :

http://guides.instructure.com/s/2204/m/4214/l/83393-how-do-i-install-and-use-curl-on-a-windows-machine

(I'm not sure that I found the correct valid CERT files)

So what do you need me to do now?

Re: Modify Resource through company website (http://<server>/adm

curl -v -X POST -d @filename.xml "http://adminuser:adminpassword@10.146.102.13:8080/adminapi/resource/" --header "Content-Type:application/xml"

or

curl -v -X POST -d @filename.xml -u adminuser:adminpassword "http://10.146.102.13:8080/adminapi/resource/" --header "Content-Type:application/xml"

New Member

Re: Modify Resource through company website (http://<server>/adm

This is my result

Re: Modify Resource through company website (http://<server>/adm

OK, try -X PUT instead of -X POST.

G.

New Member

Re: Modify Resource through company website (http://<server>/adm

Wuhuu! That worked ...

E:\Projects\Webpage\Cisco_files>curl -v -X PUT -d @XML_masterfile.xml -u rarja:password "http://10.146.102.13:8080/adminapi/resource/rarja" --header "Content

-Type:application/xml"

* About to connect() to 10.146.102.13 port 8080 (#0)

*   Trying 10.146.102.13...

* Adding handle: conn: 0x1f4c3d0

* Adding handle: send: 0

* Adding handle: recv: 0

* Curl_addHandleToPipeline: length: 1

* - Conn 0 (0x1f4c3d0) send_pipe: 1, recv_pipe: 0

* Connected to 10.146.102.13 (10.146.102.13) port 8080 (#0)

* Server auth using Basic with user 'rarja'

> PUT /adminapi/resource/rarja HTTP/1.1

> Authorization: Basic cmFyamE6U2FuZGVyMjAwOSU=

> User-Agent: curl/7.33.0

> Host: 10.146.102.13:8080

> Accept: */*

> Content-Type:application/xml

> Content-Length: 2532

> Expect: 100-continue

>

< HTTP/1.1 100 Continue

< HTTP/1.1 200 OK

< Set-Cookie: JSESSIONID=91D8D679899986645DE21036E0ABB52C; Path=/adminapi/; Http

Only

< Content-Length: 0

< Date: Wed, 18 Dec 2013 13:18:15 GMT

* Server Cisco is not blacklisted

< Server: Cisco

<

* Connection #0 to host 10.146.102.13 left intact

Re: Modify Resource through company website (http://<server>/adm

Okay, that's perfect.

Now, try to do the same with your program :-)

G.

New Member

Re: Modify Resource through company website (http://<server>/adm

That alot easier said than done it seems

Keep getting bad request no matter what I do

Re: Modify Resource through company website (http://<server>/adm

Hi, I am sorry but I cannot help you with that as I know nothing about .NET languages. A quick search at Stackoverflow got me this:

http://stackoverflow.com/questions/5939081/restful-web-service-tutorials-for-net

G.

905
Views
40
Helpful
32
Replies
CreatePlease to create content