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

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Replacing a document file using REST API

We have been able to upload, move and rename documents successfully using the REST API but we are having issues with the function which stores files in the database from a temporary folder. This is from the developer guide.

Cisco5.gif

Is there an option to overwrite the file if it already exists? Right now we are getting a "409 Conflict" error.

Cisco6.gif

Any ideas would be greatly appreciated.

Everyone's tags (4)
8 REPLIES

Replacing a document file using REST API

You need to use Modify File (PUT).

New Member

Re: Replacing a document file using REST API

Right now my solution is:

1)      upload new file – Testnew.xml

2)      rename the existing file – Test.xml to Testold.xml

3)      rename Testnew.xml to Test.xml

4)      delete Testold.xml

The reason why I want to find out if there is an overwrite option is because there is still a chance errors happen between step 2 and step 3 and if it does it may leave the system without the file which would be bad in our environment. So I’d like to combine step 2 and 3 together if possible.

Replacing a document file using REST API

Hi,

is it IP IVR or UCCX Premium? What is the License level (Premium or Enhanced or Standard)?

If it is Premium, then you can write a HTTP application which would read the actual document over HTTP and upload it to the local UCCX repository. This works with older versions of UCCX as well. Like this:

1. EnterpriseApplication creates file.xml

2. EnterpriseApplication exposes file.xml (probably by copying it to the web server document directory)

Naturally, file.xml may be dynamically generated as well.

3. EnterpriseApplication contacts UCCX, triggering a HTTP-enabled script

4. HTTP-enabled script on UCCX downloads file.xml using HTTP protocol

5. HTTP-enabled script on UCCX uploads file.xml to local document repository.

The script may be configured to silently overwrite the document in the local document repo (this is the default) or throw an exception which may be handled gracefully.

uccx-downup-script.png

G.

Replacing a document file using REST API

How are you achieving the upload in step 1?  I find the Admin API document to be insufficient to determine how to send the request.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

Replacing a document file using REST API

Using HTTP POST method with UploadFile

Cisco7.gif

Our version of UCCX is standard.

Replacing a document file using REST API

Oh right, but I meant like how are you constructing your request.  Could you somehow post your raw HTTP request for me to review?  Sorry, I know this is not helping you now, but I needed to get this piece figured out, before I can move forward to assist with the other part.  Kind of like a "help me help you" type of a deal. 

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

Replacing a document file using REST API

Anthony,

Here are the raw HTTP request for upload.

POST http://192.168.1.100/adminapi/document/uploadFile HTTP/1.1
Host: 192.168.1.100
Connection: keep-alive
Content-Length: 335
Authorization: Basic cfdffsfdsfdfsddsfmlasss9jw==
Cache-Control: no-cache
Origin: chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36
Content-Type: multipart/form-data; boundary=----28947758029299
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,zh-TW;q=0.2

------28947758029299
Content-Disposition: form-data; name="mimetype"

multipart/form-data
------28947758029299
Content-Disposition: form-data; name="file"; filename="Test.xml"
Content-Type: text/xml


 
30.0
20.0
 

-------------------------------28947758029299--

Following are the HTTP request for save:

POST http://192.168.1.100/adminapi/document/ HTTP/1.1
Host: 192.168.1.100
Connection: keep-alive
Content-Length: 147
Authorization: Basic cfdffsfdsfdfsddsfmlasss9jw==
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36
Cache-Control: no-cache
Origin: chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm
Content-Type: application/XML
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,zh-TW;q=0.2


 
   
      /en_US/
      Test.xml
   
 

Replacing a document file using REST API

Thanks for posting the request.  I was trying something similar but not having any luck.  I guess that's why it's not very smart to hand code your requests.

Anyway, the API is new and not well documented, and therefore we're all kind of learning together.

In the event that there is not an overwrite feature, here's a solution that will not leave you high and dry between steps 2 and 3.

  1. Upload your new file as: test.new.xml
  2. Rename your existing file as: test.original.xml
  3. Something goes wrong with the REST client
  4. Your UCCX script runs and detects the exception when the file is missing, and then falls back to using the filename  test.original.xml.
  5. If you recover from the failure and end up restoring the test.xml file, the script will automatically begin using it again.

Or..a similar but slightly different approach:

  1. Have a static default state XML file in the default language folder named test.xml
  2. Upload your new file as: test.new.xml
  3. Rename your existing file as: test.original.xml
  4. Something foes wrong with the REST client
  5. UCCX will automatically search for text.xml in en_US, en, then default
  6. If you recover from the failure and end up restoring the text.xml file in the en_US (or en) language folder, the script will automatically begin using it again.

I hope that helps.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
997
Views
0
Helpful
8
Replies
CreatePlease login to create content