Upload file using WebDAV protocol fails

Advertisement

tom.vers
Guest

Upload file using WebDAV protocol fails

Hi,

I'm developing a .NET core app (no GUI, just a service that runs jobs once in a while). It checks if a file exists on a WebDAV folder, if not, it copies the file to the target.
I am able to list the files in the WebDAV folder (When Debugging, I can see the list of fetched files).
I use WinSCP NuGet version 5.21.5 (currently the latest)
However, when I try to upload the file using session.PutFileToDirectory, I get the following error:
Error transferring file 'C:\dev\ConfiDesk\confidesk-api\Confidesk.Api\LocalTmpStorage\CDA128-20221118-OR1TMAA19K.TXT'.
WebDAV resource moved to '**'.
302 Moved Temporarily
=> '**' was not the host I configured for the session. I also cannot see the file on the target folder, it clearly failed. But I cannot see what went wrong. Can you please assist?
In order to give you more feedback, I attached a debugLog (I tried also creating a session log by setting the SessionLogPath, but the logfile does not get created.
In the debuglog file, you can see, before the mention of 302 Moved temporarily, there is a mention of 502 Bad Gateway. Maybe this points to the actual problem?
Please let me know if you need any more information.

Thank you!
  • debuglog.txt (69.07 KB, Private file)

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

Re: Upload file using WebDAV protocol fails

Please try to get the session log. It shouldn't be difficult to make it working. If you have problems, please post your code and debug log of the session, where session logging isn't working.

Reply with quote

tom.vers
Guest

Session log

Hi,

I found the session log. Apparently it was saved in a different location then the debug log, even tough I set no folder for both Paths. Since I didn't see it, I thought it was not generated :)
See attachment for the session log.

Thanks for looking into this!
  • sessionlog.txt (85.17 KB, Private file)
Description: the sessionlog

Reply with quote

martin
Site Admin
martin avatar

Re: Session log

It seems the server is redirecting you to some login page that asks for "client code". Is that expected? I do not see how this can work with WebDAV clients. Can you upload the file using any WebDAV client at all?

Reply with quote

tom.vers
Guest

winscp client

Hello,

Yes, when using the same credentials for opening a session in WinSCP client, I can copy a file there manually.
In code, I can list files, the problem only arise when calling PutFileToDirectory.

Regards

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: winscp client

I assume that by "WinSCP client", you mean the WinSCP GUI. If that's connect, please post complete GUI session log file showing a successful upload.

Reply with quote

tom.vers
Guest

WebDAV GUI log

Hi,

Yes, I meant WinSCP GUI. See attachment for the log file you requested. Hopefully this clarifies the proces.
I don't think it's normal a 'client code' is requested. Since I don't have to enter one on the GUI, I would expect it to work also without a 'client code' using the WinSCP NuGet package?

Regards
  • webdav-POV.log (28.88 KB, Private file)

Reply with quote

tom.vers
Guest

folder paths

Hi,

I had set the rootfolder, so I assumed this root folder shouldn't be repeated any longer. But it was indeed the cause of the problem. The wrong path caused the 302 redirect to some login page because the directory was not allowed/accessible.
I had already tried including the full path as second arg in PutFileToDirectory using RemotePath.Combine(), however, during debugging I now see the paths don't get attached (in fact, I only get the second string returned, being /TestCoda)
When I attach them manually (rootFolder + targetfolder) I see it works now, I see the file arrived using WinSCP GUI!

Thank you so much for the support!

Regards

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum