0

I have an SSIS script running which uses a C# script to run a webclient to download a currencies file from XE.com. Unfortunately, the path XE provide has a cgi call and hence a question mark in it which is an illegal character, so I receive the following when I run the script:

System.ArgumentException: Illegal characters in path.

The script I used was just adapted from these instructions: How to make an HTTP request from SSIS?

Is there a way of replacing the question mark with an ASCII code or something?

Many thanks in advance.

Community
  • 1
  • 1
Loic
  • 111
  • 8
  • I'm having trouble reproducing this. I can use .Net 4.5.x's WebClient to download from URIs containing strings with question marks without a problem. What version of .Net are you using? Can you post the code from your Script Task? – Ben Gribaudo Oct 03 '14 at 16:24

1 Answers1

0

Thanks for the response, Ben. Bear in mins this is an SSIS script task, with the code from the aforementioned guide. I ended up replacing the question mark with ASCII code ? which did the trick. For future readers, the code in question:

public void Main()
{
    Variables varCollection = null;

    Dts.VariableDispenser.LockForRead("User::RemoteUri");
    Dts.VariableDispenser.LockForRead("User::LocalFolder");
    Dts.VariableDispenser.GetVariables(ref varCollection);

    System.Net.WebClient myWebClient = new System.Net.WebClient();
    string webResource = varCollection["User::RemoteUri"].Value.ToString();
    string fileName = varCollection["User::LocalFolder"].Value.ToString() + webResource.Substring(webResource.LastIndexOf('/') + 1);
    myWebClient.DownloadFile(webResource, fileName);

    Dts.TaskResult = (int)ScriptResults.Success;
}
Ben Gribaudo
  • 5,057
  • 1
  • 40
  • 75
Loic
  • 111
  • 8
  • Thanks, @Loic! I'm confused by: "I ended up replacing the question mark with ? which did the trick." "?" is the question mark character! :-) Was the character originally something other than "?"? – Ben Gribaudo Oct 03 '14 at 18:43
  • Hi Ben, the site had rendered the question mark - I'd put the ASCII code in to resolve issue. Fixed my response. – Loic Oct 06 '14 at 08:02
  • thanks! Was your original URL like http://example.com/cgi?name=Frank or http://example.com/cgi?action=something?name=Frank (with two question marks)? – Ben Gribaudo Oct 09 '14 at 17:33