I'm currently working on implementing asynchronous file uploads using the jquery.form plugin with the ajaxSubmit method. The backend process involves taking the uploaded document and inserting it into a document library, which is working fine. However, when attempting to upload a file, I keep receiving a 404 bad request error. It seems that the webservice is expecting JSON in the request, but the payload I'm sending looks something like this:
Content-Disposition: form-data; name="file"; filename="Json45r11 (1).zip"
Since this isn't in JSON format, I believe this is causing the bad request error. The backend webservice method definition looks like this:
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest , ResponseFormat = WebMessageFormat.Json)]
SuccessUpload uploadDoc(string id);
The frontend submission code appears as follows:
$('#form').ajaxSubmit({url: 'backend Method', type: 'post',data: JSON.stringify({id:1})});
Is there any way around this issue? Any assistance would be greatly appreciated. Apologies for any language barriers.