Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3608648
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:31:39+00:00 2026-05-18T21:31:39+00:00

I need to consume a service that takes a GET parameter named names[]. For

  • 0

I need to consume a service that takes a GET parameter named “names[]”.

For example: GET http://example.com/name2id?names[]=john

When I try to consume that in C# using a WebClient, the brackets gets encoded to %5B%5D, which the servies does not understand. When I send the above using my browser (un-encoded), everything works fine.

Heres the example that does not work:

using (var client = new System.Net.WebClient())
{
    response = client.DownloadString(new Uri("http://example.com/name2id?names[]=john"));
}

Monitored by fiddler, heres the request:

GET http://example.com/name2id?names%5B%5D=john HTTP/1.1
Host: example.com
Connection: Keep-Alive

Is there any way to make the framework NOT encode the URL, or some other way around this issue?

P.S. I do not control the API so I cannot change that.

UPDATE:

This is kinda wierd. I found a solution, changing my C# code to:

using (var client = new System.Net.WebClient())
{
    response = client.DownloadString(new Uri("http://example.com/name2id?names[]=john", true));
}

Note the boolean dontEscape in Uri. It is actually deprecated, but it works? Can anyone explain this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:31:39+00:00Added an answer on May 18, 2026 at 9:31 pm

    As mentioned by CodeInChaos, the URL is not valid according to RFC2396.

    To make C# not escape invalid characters, the overloaded method of URI can be usen:

    new Uri("http://example.com/name2id?names[]=john", true)
    

    However, this method is deprecated but apparently it still works. I have to live with the warning popping up 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use asp.net 2 and need to consume a 3rd party HTTP GET call
I need to consume a Web Service via SSL. In order to accomplish that
I am going to need a web service that receives a string via HTTP
So I need to consume a Web Service that uses a custom SoapHeader, as
I have a web service that I need to consume from BizTalk orchestration. I've
I need to consume a web service from android/eclipse by soap method. ie., i
I use jersey-client to consume a REST service. I need both the requested Entity
I have a REST webservice that I need to consume in C#. I need
I need to write an application (not a sevrice or web service) that consumes
I have received few WSDLs and XSD defining a service that I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.