I need to have 2 Gets in my rest web service the first Get takes 5 parameters, while the 2nd one takes 7 different parameters
I know that we can have default Get without parameters but how can we have 2 Gets with both have parameters?
thanks
both gets are needed
public string Get(Int64 id, string UserID, int Val1, int Val2, int Val3)
{
}
public int Get(string FirstName, string LastName, int Age, int Tall, int Size, string Code, string Address)
{
}
you can use the following tips if you want
// GET: api/Default
public IEnumerable<string> Get( string p1, string p2, string p3, string p4, string p5, string p6=null,string p7=null)
{
return new string[] { "value1", "value2" };
}
if you pass 5 arguments your 6 and 7 will be null or 7 arguments with same action
Or you can define 2 gets like the following
// GET: api/Default
public IEnumerable<string> Get( string p1, string p2, string p3, string p4, string p5)
{
return new string[] { "value1", "value2" };
}
and 7 parameters
// GET: api/Default
public IEnumerable<string> Get( string p1, string p2, string p3, string p4, string p5, string p6,string p7)
{
return new string[] { "value1", "value2" };
}
you have to use the following uri for example
http://localhost:53383/api/default?p1=tes&p2=tesff&p3=tes&p4=tesffs&p5=tesffs
and for the action with 7 parameters
http://localhost:53383/api/default?p1=tes&p2=tesff&p3=tes&p4=tesffs&p5=tesffs&p6=tesp6&p7=tesp7
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.