LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Webservice upload file post multipart error

Solved!
Go to solution

I am making a webservice with LV2020-32 and I have created a VI that serves a html form to a browser. The form markup uses POST and the form attribute enctype="multipart/form-data", which supposedly is required if you want to upload a file. The POST request is handled by another vi, but it never receives the file. If I call "Read Postdata.vi" I actually also get an error -67032 that states that the NI webservice does not support multipart bodies. This is not true, because "read all form data.vi" will accept the multipart body.  It will however not return any uploaded files.

 

Lastly, I tried the "Read uploaded files.vi", but it, too, never returns any uploaded files. It gave met error -67023 too: An operating system exception encountered.

 

I also tried "enable CORS for all origins" just to rule out that the browser is making a distinction in content based on mime-type.

I have checked the POST request made by the HTML form, which is completely fine.

 

Any ideas anyone?

0 Kudos
Message 1 of 9
(2,035 Views)

I wonder why there's not one response to my question so far. It seems like a fairly basic thing to do with a webserver. The webservice toolkit even has a VI to return the uploaded files. It really should be quite simple to upload a file through a webform. What am I missing?

0 Kudos
Message 2 of 9
(1,963 Views)

By adding a response myself, NI no longer got a trigger to provide support on this question. I am really surprised that there is no response at all on this question.

 

I did find out that behind the NI web server there is a basic install of Systemlink. Maybe the ability to upload files depends on settings inside Systemlink instead. However, I can't find any relevant documentation on this particular subject.

0 Kudos
Message 3 of 9
(1,918 Views)

Hi, Do you resolve your problem? I have the same problem.

0 Kudos
Message 4 of 9
(1,470 Views)

No, I have yet to resolve this issue. I decided to make a labview based client first. In labview, I am able to upload a file, simply as flattened base64 data in a simple POST. In HTML I may not have that option.

0 Kudos
Message 5 of 9
(1,359 Views)
Solution
Accepted by topic author aartjan

To any that find this:

 

I was having the same issue, and the only way I got it to work was to run the built exe as an administrator.  If I ran it directly from LabVIEW I get error: "-67032".  Note, I also added the error cluster to the terminals to make it easier to see the issue.

 

I used the VIs show here: https://forums.ni.com/t5/LabVIEW/Upload-file-with-LabVIEW-webservices/m-p/4100691#M1181323

 

EvanCo_0-1689346619664.png

 

0 Kudos
Message 6 of 9
(1,194 Views)

Thanks for that tip! Will give it a try.

0 Kudos
Message 7 of 9
(1,183 Views)

It was correct. I started Labview in admin mode and was able to receive the file (running the webservice in the project). Indeed, you must also move the file right away. As soon as the request is done, the file will disappear, too.

 

Very weird, though, that it has to run in admin mode. Also a shame one can't read the multipart body.

0 Kudos
Message 8 of 9
(851 Views)

Although I accepted the explanation as a solution, it really is just an explanation, which includes a possible workaround. I just figured out what the root cause is of the issue: The temporary upload file is written to C:\ProgramData\National Instruments\WebServices\amqp_temp

This folder requires admin rights, and therefore the app fails when not running in admin mode. I will attempt to report it as a bug to NI.

0 Kudos
Message 9 of 9
(206 Views)