Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to create a web api and want response like

<school>
< Student>1
<teacher>1
<ofcboy>1
< Book>1


How i will create web api where student and Teacher will be pass from parameter.

What I have tried:

[HttpGet]

public HttpResponseMessage GetData(string user, string pass)
{
    Account account = new Account();
    account.username = user;
    account.password = pass;
    account.host = "1.2.3.4";
    account.codecOrder = "9,0,8,102,3";
    account.codecOrder3G = "102,3,9,0,8";

    // return account;
    var content = new ObjectContent<Account>(account,
                    (Configuration.Formatters.XmlFormatter));

    return new HttpResponseMessage()
    {
        Content = content
    };


}


I have created like this but getting namespace of XML
Posted
Updated 17-Jun-19 21:40pm

 
Share this answer
 
Comments
Maciej Los 18-Jun-19 3:19am    
:D5ed!
:D
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900