cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2118
Views
50
Helpful
32
Replies

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

RarJacobsen
Level 1
Level 1

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 32

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.

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

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.

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

RarJacobsen
Level 1
Level 1

Hi G.

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

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.

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

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

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?

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"

This is my result

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

G.

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

Okay, that's perfect.

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

G.

That alot easier said than done it seems

Keep getting bad request no matter what I do

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.