Hi,
How did you post the file? I suppose you have a page to select the file and then post it to ServiceAPI?
This should not be permission issue. It's only suggestion of the most common cause, but the true error was this:
Unexpected end of MIME multipart stream. MIME multipart message is not complete.
So I guess it's how you send the file to ServiceAPI. If you are using an input to select the file, perhaps adding name attribute to it will help.
Regards,
/Q
Hi
Thanks for your quick reply. I'm using a filestream to pick up the file directly from the file system. As mentioned in my post I'm using the exact sample code off World that shows a sample request of submitting the file. The code from world that I'm using is below:
using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://mysite.com/"); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); var content = new MultipartFormDataContent(); var filestream = new FileStream(path, FileMode.Open); content.Add(new StreamContent(filestream), "file", "Catalog.zip"); var response = client.PostAsync("/episerverapi/commerce/import/catalog", content).Result; if (response.StatusCode == HttpStatusCode.OK) { var returnString = response.Content.ReadAsStringAsync().Result; returnString = returnString.Replace("\"", ""); Guid taskId = Guid.Empty; Guid.TryParse(returnString, out taskId); } }
I have tried using this code from a console application as well as from just a basic webforms page. I get the same exception from both. I've also tried changing the contents of the Catalog.xml and re-zipping etc. Is this code the correct way of calling the service? This was taken from http://world.episerver.com/documentation/Items/Episerver-Service-API/Using-bulk-import-and-export-methods/Using-the-catalog-service/
Thanks for your help,
Damo
Hi,
Shouldn't this line
var filestream = new FileStream(path, FileMode.Open);
be this:
var filestream = new FileStream(path, FileMode.Open, FileAccess.Read);
?
/Q
Hi Quan,
With and without the access parameter I get the same error. I tried both. Do you have any sample code with the catalog import working? Since my post I've tried a few different ways to send the post but I still get the same error message.
Thanks,
Damien
Hi,
No, I don't have anything else. The code is supposed to work with other sites - I haven't heard issues related to it.
How big is your catalog.zip btw? Is there any chance it's more than 4 MB?
/Q
Ye old httpruntime max limit of bytes :)
I wonder how many developer life times has been spent on that one overall...
Hi Guys,
No I haven't resolved the issue as yet. I followed the setup guide for the service API so have already set the httpruntime attributes as well as the <system.webserver> attributes as well.
I'm probably at the stage where I'll need to log a support ticket now. Last night I also tried it from the Quicksilver demo project. I added the EPiServer.ServiceAPI.Commerce nuget package to the Commerce Manager. Then I setup a simple console application running the code above but I still got the same error.
Regarding the catalog zip file I updated it to almost contain nothing in it just to try and get successful post. It just contains the required tags with one product in it. The size of the zip is only 10KB. So size shouldn't be a problem.
Kind of out of ideas now as to what is causing this.
Thanks,
Damo
Hi,
You can always contact our support services. Our developer supports there can diagnose the problem easier if they have all the information in place.
Regards,
/Q
Hi Quan,
Yes I'm going to log a support ticket. Thanks anyway for your help.
Regards,
Damien
Hi Damien,
A quick google suggests that this is a ASP.net problem and might be solved by adding a newline at the end of the document.
http://stackoverflow.com/questions/13770536/asp-net-web-api-unexpected-end-of-mime-multi-part-stream-when-uploading-from-fl
Could you upload the file you used?
Hi Toni,
Thanks for your post. I also came across this post during my troubleshooting. I also tried adding a newline to the end of the file by converting the file to a memory stream and then adding the new line and sending the memory stream through to the service API. This still returned the same error. The code I used I took from a comment on that stackoverflow post and is shown below.
Stream reqStream = Request.Content.ReadAsStreamAsync().Result; MemoryStream tempStream = new MemoryStream(); reqStream.CopyTo(tempStream); tempStream.Seek(0, SeekOrigin.End); StreamWriter writer = new StreamWriter(tempStream); writer.WriteLine(); writer.Flush(); tempStream.Position = 0;
The zip file I'm using is quite basic and just has a test node and test product. I've shared it from my onedrive account which you can download from https://onedrive.live.com/redir?resid=6ED8BBB6B90803D2!20027&authkey=!AL2-5CyffXifeeE&ithint=folder%2czip
Thanks,
Damien
Hi Damien,
Using EPiServer.ServiceApi.Client I can import your catalog in both Seagull, Quicksilver FRONT-sites.
But cannot import that on Commerce Manager.
So you can try again with Commerce site (not Manager site).
Hi David,
Thanks for the information you've posted. I can verify that the bulk catalog import does work from the CMS and Commerce site.
So for anyone looking at using the Service API you should ONLY add the Service API to either the CMS site or commerce site. Not exactly sure what the issue is when adding it to the Commerce Manager but it doesn't work.
Thanks for helping me out with this guys.
Regards,
Damien
Hi,
The document here stated that you should only install ServiceAPI to your Episerver based solution - either Commerce Sample or your actual solution: http://world.episerver.com/documentation/Items/Episerver-Service-API/Configuration-and-overview/Setting-up-EPiServerServiceApi/
We'll make it clear that we do not support install on Commerce Manager.
Regards,
/Q
Hi All,
I've been trying to use the new Service API to perform regular imports and updates to a catalog. But I'm really struggling to get the POST to /episerverapi/commerce/import/catalog to work. The exception stack trace is shown below.
2016-03-20 09:31:40,097 [116] ERROR EPiServer.ServiceApi.Extensions.HttpRequestMessageExtensions: File is not uploaded, please check permission on your app data folder in episerverframework.config file.d__0.MoveNext()d__8.MoveNext()d__0`1.MoveNext()d__0.MoveNext()d__0.MoveNext()d__8.MoveNext()d__0`1.MoveNext()d__0.MoveNext()
System.IO.IOException: Unexpected end of MIME multipart stream. MIME multipart message is not complete.
at System.Net.Http.Formatting.Parsers.MimeMultipartBodyPartParser.
at System.Net.Http.HttpContentMultipartExtensions.
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Net.Http.HttpContentMultipartExtensions.
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at EPiServer.ServiceApi.Extensions.HttpRequestMessageExtensions.
System.IO.IOException: Unexpected end of MIME multipart stream. MIME multipart message is not complete.
at System.Net.Http.Formatting.Parsers.MimeMultipartBodyPartParser.
at System.Net.Http.HttpContentMultipartExtensions.
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Net.Http.HttpContentMultipartExtensions.
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at EPiServer.ServiceApi.Extensions.HttpRequestMessageExtensions.
I know the error message says to check the permissions on the app_Data folder. But I've double and triple checked permissions even to the point of adding full writes on the folder to everyone. I'm kind of thinking this may not be a permissions issue because the service does get to the point of creating the "integration" folder under App_Data before the exception is thrown.
Just in case it was something to do with permissions I've also now changed computers to see if it was some sort of security restriction on my office computer. But that is not the case as I get the same issue at home.
Been looking into this for the last few days and can't think of anything else to try so any help is greatly appreciated. Please note I've tried the majority of the other operations and they all work fine. It is just the bulk catalog import/update that is causing me grief.
The versions I'm using are:
EPiServer CMS v9.7.2
EPiServer Commerce v9.10
EPiServer Service API v2.05
The code I'm using to make the request is identical to what is shown on http://world.episerver.com/documentation/Items/Episerver-Service-API/Using-bulk-import-and-export-methods/Using-the-catalog-service/
Thanks heaps,
Damo