Thursday, 31 July 2014

JQuery-Upload: unexpected token

While working with the JQuery-Upload control, I encountered the following error:

unexpected token <

The real kicker was the fact that my target file was still being created.

The cause of the problem (as I eventually discovered) was my REST contract; my endpoint as configured as follows:

[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.WrappedResponse,
UriTemplate = "/file/upload")]
StatusData Upload(Stream fileData);

but my endpoint was returning a JSON response.

This resulted in a mismatch, as the expected response format was XML.

Changing the contract to Json resolved the problem.

No comments:

Post a comment