Passing String array in get request in url

Posted on 2011-10-18
Last Modified: 2012-06-21

I have a web service exposed in my local box and am trying to send a get request to that service which takes GET requests.

The following url works :

but the apiNames in the above url is actually a String array.  I could only pass one string but here i need to pass a collection of apiNames in the url.  I tries the following things but it didn't work for me.

apiNames=[references, services]
apiNames=[references, services]
apiNames=[[references], [services]]
apiNames={references, services}

Can any one help me the correct syntax to pass a String array in url ?

Question by:lakkarajumurali
    LVL 47

    Accepted Solution

    maybe this will work like in this case:

    You have a few options here.
    Option 1: A query parameter with multiple values

    You can supply multiple simple values for a single query parameter. For example, your query string might look like:

    PUT /path/to/my/resource?param1=value1&param1=value2&param1=value3

    Here the request parameter param1 has three values, and the container will give you access to all three values as an array (See Query string structure).
    LVL 47

    Expert Comment

    see also here

    Multiple values can also be associated with a single field:


    For each field of the form, the query string contains a pair field=value. Web forms may include fields that are not visible to the user; these fields are included in the query string when the form is submitted

    This convention is a W3C recommendation.[3] W3C recommends that all web servers support semicolon separators in the place of ampersand separators.[4]

    Technically, the form content is only encoded as a query string when the form submission method is GET. The same encoding is used by default when the submission method is POST, but the result is not sent as a query string, that is, is not added to the action URL of the form. Rather, the string is sent as the body of the HTTP request.

    Author Closing Comment

    Thank you it worked!!
    LVL 86

    Expert Comment

    >>PUT /path/to/my/resource?param1=value1&param1=value2&param1=value3

    You don't want to do that probably. The GET query string is already limited in length as it is.

    More likely your problem was caused by incorrect url-encoding of the query string

    Author Comment

    Hi Cehj,

    the service accepts GET requests and it does not allow the user to create or update the data in the db but we get data from that service.  The solution which Yan send me work perfectly fine and as such we will be sending not more than 3 values in an array which is well within 255 char deadline.

    Thank you all for the reply.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Introduction One of the frequent application design questions goes something like this: "How can I confirm when a client registers on my web site?" The registration might be for general use of a self-administered site like a forum, or for attend…
    While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now