This is a migrated thread and some comments may be shown as answers.

OData Service: Invalid slug header for attachment.

1 Answer 122 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Robert Kaucher
Top achievements
Rank 2
Robert Kaucher asked on 09 Jun 2013, 02:10 AM
I am trying to upload a file via a service that implements OData. I cannot seem to set any additional headers on the upload control. I need to set a custom slug header.

Here is the error I am receiving. Despite what it says the header format is below the error.

Invalid slug header for attachment. Slug headers must be of the form "EntitySet,ItemId,Name".

Here is how the headers should look:
    Slug: MyListTitle|1|mydocument.docx

1 Answer, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 11 Jun 2013, 07:50 AM
Hi,

The latest version of the Upload supplies a reference to the XMLHttpRequest in the upload event.
This will work only in non-IE browsers, as we use an IFRAME as a fallback in IE.

        function(e) {
          var xhr = e.XMLHttpRequest;
          if (xhr) {
            xhr.addEventListener("readystatechange", function(e) {
              if (xhr.readyState === 1 /* OPENED */) {
                xhr.setRequestHeader("Slug", "MyListTitle|1|mydocument.docx");
              }
            });
          }
        }


Demo: http://jsbin.com/uwitun/1/edit

I hope this helps.

Regards,
Tsvetomir Tsonev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Upload
Asked by
Robert Kaucher
Top achievements
Rank 2
Answers by
T. Tsonev
Telerik team
Share this question
or