locked
Wep Api + Get method with complex input parameter RRS feed

  • Question

  • User919378809 posted

    Hi All,

    I have a requirement to get data from web api passing complex object as input - search criteria parameter like first name, last name, dob, zip and ssn informtion.  How will I pass this object to web api get method so that I can retrieve data based on criteria.  Please give me a sample how to pass an object to web api method.

    Thanks

    Selvakumar R

    Saturday, April 7, 2018 5:30 AM

Answers

  • User475983607 posted

    I have a requirement to get data from web api passing complex object as input - search criteria parameter like first name, last name, dob, zip and ssn informtion.  How will I pass this object to web api get method so that I can retrieve data based on criteria.  Please give me a sample how to pass an object to web api method.

    This site has excellent tutorials which show how to accomplish fundamental concepts like passing data to an action.

    https://docs.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/

    Try reading the docs first.  If you run into problems then post your questions here and I'm sure someone will be able to help.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 7, 2018 12:07 PM
  • User-474980206 posted

    the GET method only supports url query string parameters, so it would be:

       https://myurl.com/api/mymethod?firstName=john&lastName=smith&dob=1960-01-01&zip=98000&ssn-555-55-5555

    note the parameter values must be url encoded. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 7, 2018 5:34 PM

All replies

  • User475983607 posted

    I have a requirement to get data from web api passing complex object as input - search criteria parameter like first name, last name, dob, zip and ssn informtion.  How will I pass this object to web api get method so that I can retrieve data based on criteria.  Please give me a sample how to pass an object to web api method.

    This site has excellent tutorials which show how to accomplish fundamental concepts like passing data to an action.

    https://docs.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/

    Try reading the docs first.  If you run into problems then post your questions here and I'm sure someone will be able to help.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 7, 2018 12:07 PM
  • User-474980206 posted

    the GET method only supports url query string parameters, so it would be:

       https://myurl.com/api/mymethod?firstName=john&lastName=smith&dob=1960-01-01&zip=98000&ssn-555-55-5555

    note the parameter values must be url encoded. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 7, 2018 5:34 PM