12-17-2013 12:58 AM - edited 03-14-2019 12:53 PM
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
12-17-2013 06:19 AM
Strange, I cant seem to generate a new catalina file now.
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.
12-17-2013 06:26 AM
12-17-2013 06:43 AM
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.
12-18-2013 01:46 AM
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
12-18-2013 03:09 AM
12-18-2013 03:14 AM
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.
12-18-2013 03:16 AM
If I remove it, I'm asked to type it in.
I'm still trying to get curl to install/work
12-18-2013 04:11 AM
Now I think Curl is installed according to :
(I'm not sure that I found the correct valid CERT files)
So what do you need me to do now?
12-18-2013 04:52 AM
curl -v -X POST -d @filename.xml "http://adminuser:adminpassword@10.146.102.13:8080/adminapi/resource/
or
curl -v -X POST -d @filename.xml -u adminuser:adminpassword "http://10.146.102.13:8080/adminapi/resource/
12-18-2013 05:05 AM
12-18-2013 05:08 AM
OK, try -X PUT instead of -X POST.
G.
12-18-2013 05:37 AM
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
12-18-2013 05:41 AM
Okay, that's perfect.
Now, try to do the same with your program :-)
G.
12-19-2013 10:29 AM
That alot easier said than done it seems
Keep getting bad request no matter what I do
12-19-2013 10:36 AM
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.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide