Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-4421

WP8 Project - XHRHelper.HandleCommand failing with 'System.InvalidOperationException: This operation is not supported for a relative URI" error

    XMLWordPrintableJSON

Details

    Description

      In the WP8 application we are developing, when the following code is being executed -

      $.get("/www/folder/to/devConfig.txt").done( function(content) {
      settings = JSON.parse(content)
      } );

      I get the following exception:

      {System.InvalidOperationException: This operation is not supported for a relative URI.
      at System.Uri.get_AbsolutePath()
      at WPCordovaClassLib.CordovaLib.XHRHelper.HandleCommand(String commandStr)
      at WPCordovaClassLib.CordovaView.CordovaBrowser_Sc...

      I tried various combination such as:

      • "file:///www/folder/to/devConfig.txt" and "file://localhost/folder/to/devConfig.txt", which translated to "/www/folder/to/devConfig.txt", in the relative path.

      In these cases I received a 404 error.

      Reading through the documentation, it seems that the first "/" needs to be removed for the relative path to work, instead of "/www/folder/to/devConfig.txt" should be "www/folder/to/devconfig.txt".

      Sending "www/folder/to/devconfig.txt", causes the first exception.

      As a fix, I have modified the XHRHelper code to check for isAbsoluteUri condition and remove the first "/" if it is a relative path. That seems to work. But it is not a future proof solution.

      Please advise.

      Attachments

        Activity

          People

            purplecabbage Jesse MacFadyen
            shashankb Shashank Banerjea
            Votes:
            4 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: