"Error 401 - Cannot authenticate over ajax calls" on iOS


#1

Hi, I'm writing an app (using Ionic 2) that uploads pictures to my ownCloud server via Webdav. Here is the relevant part of my code:

upload(imgToUpload) {
  let transfer = new Transfer();
  let URL: "https://username:password@owncloud.../remote.php/webdav/folder/"
  let options = {
    httpMethod: "PUT"
  }

  transfer.upload(imgToUpload, URL, options, true).then(
    (succ) => {},
    (err) => {console.log(err.http_status+" "+err.body);}

I'm using the Ionic File Transfer Plugin which internally uses a PUT request. The whole thing works on Android, but on iOS I get the following error:

401 <?xml version="1.0" encoding="utf-8"?> 
  <d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
    <s:exception>Sabre\DAV\Exception\NotAuthenticated</s:exception>
    <s:message>Cannot authenticate over ajax calls</s:message>
  </d:error>

I'm using basic authentication. I looked through the ownCloud source code and it seems that the error originates here but I don't see why it's thrown or why this only happens on iOS.

Can anyone help me get this sorted out?
Thanks in advance!


#2

If it works from Android but not from IOS then i guess that framework is doing something different between both platforms.

Have you considered asking at e.g. https://forum.ionicframework.com ? They might be able to explain you the differences here.


#3

Thanks, I'll try that