Topic: .wln messages import returns error 4
Hello Gurtam,
I am currently trying to import .wln messages from the api, as described in https://sdk.wialon.com/wiki/en/kit/remo … t_messages
The message format I adhere to is as described in https://sdk.wialon.com/wiki/en/kit/remo … t/messages
Now, I've double and triple checked the Post request I send as well as the upload file. As a proof there are two upload zip files attached, one with the simplest message entry possible, and one with two message entries with a bit more data substance. I've also tried to upload them via the Wialon hosting UI, quite successfully. The post request headers and content are set exactly as specified in the documentation, nevertheless here is the c# code that does that.
using (Stream fs = await file.OpenAsync(PCLStorage.FileAccess.Read))
{
var streamContent = new StreamContent(fs);
streamContent.Headers.ContentType = MediaTypeHeaderValue.Parse("application/zip");
using (var client = new HttpClient())
using (var formData = new MultipartFormDataContent())
{
client.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "text / html,application / xhtml + xml,application / xml; q = 0.9,*/*;q=0.8");
client.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Charset", "windows-1251,utf-8;q=0.7,*;q=0.3");
client.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Language", "ru,en-US;q=0.8,en;q=0.6");
client.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Encoding", "gzip, deflate, sdch");
formData.Add(streamContent, "messages_filter_import_file", file.Name);
formData.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data");
var response = await client.PostAsync(url, formData);
if (!response.IsSuccessStatusCode)
{
return null;
}
return await response.Content.ReadAsStringAsync();
}
}
I also attach the sniffed http communication from my device to the remote API, which exactly mimics your example.
Now, always getting the impossible to debug on my side error 4, could you give me a hint what might possibly be going wrong.