I am new to iOS. I searched similar questions but couldn't find right answer for my situation.
I created asp.net web api (slected only web api option not selected MVC option)
But I made model Account and controller AccountsController
which is an ApiContoller
in my AccountsController:
[Authorize]
// GET: api/Accounts
public IQueryable<Account> GetAccounts()
{
return db.Accounts;
}
// GET: api/Accounts/5
[ResponseType(typeof(Account))]
[Route("api/account/{id}")]
public IHttpActionResult GetAccount(int id)
{
Account account = db.Accounts.Find(id);
if (account == null)
{
return NotFound();
}
return Ok(account);
}
And my Account model:
public class Account
{
public int Id { get; set; }
public string UserName { get; set; }
public string UserEmail { get; set; }
public decimal Rebate { get; set; }
public decimal MemCom { get; set; }
}
When I run http://tresmorewebapi.azurewebsites.net/api/accounts
I get all lists of accounts.
How can I create simple ios app in swift that shows lists of Account table? And after I inserted [Authorize] to AccountsController, I get error message Authorization has been denied for this request
by same http GET request http://tresmorewebapi.azurewebsites.net/api/accounts
How can I send http request with authorization..?
I guess anyone who read this question can POST to my server..??
If someone can lead me to this step.. I think I can get further..
Thank you very much!