0

I need to call a webAPI with string array as a parameter.

I have a string array . I need to call this api from c#

string[] str;
str[0]= "abc";
str[1]= "xyz";

how can I create the api request call like given below.

http://localhost:59511/api/Values?str[]="abc"&str[]="xyz"
2
  • 1
    I would advise you to make it as a POST request with JSON body containing your array, if possible Commented Oct 7, 2019 at 10:17
  • Either create custom model binder or use solution @Craig H provided below, it's default behavior of web api for sending arrays Commented Oct 7, 2019 at 18:49

1 Answer 1

1

You can format the request like so:

http://localhost/api/values?str=abc&str=xyz
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.