Answer the question
In order to leave comments, you need to log in
How to accept model from Get request in WebAPI 2?
Hello!
Project: ASP.NET WebAPI 2
Required to accept from a GET string of type: URL?txn_id=20193504262040&txn_date=1491471490074&account=7013954927&trm_id=952
there is a class:
public class Payment
{
public long Id { get; set; }
public long TxnId { get; set; }
public DateTime TxnDate { get; set; }
public string Account { get; set; }
public long TrmId { get; set; }
public long PrvId { get; set; }
public string ProviderName { get; set; }
public int TrmType { get; set; }
public double FromAmount { get; set; }
public double ToAmount { get; set; }
}
public IHttpActionResult Get([FromUri] Payment payment)
{}
public IHttpActionResult Get([FromUri(Name = "txn_id")] long txnId,
[FromUri(Name = "txn_date")] string txnDate,
[FromUri(Name = "account")] string account,
[FromUri(Name = "trm_id")] long trmId,
[FromUri(Name = "prv_id")] long prvId,
[FromUri(Name = "trm_type")] int trmType,
[FromUri(Name = "prv_name")] string prvName,
[FromUri(Name = "from_amount")] double fromAmount,
[FromUri(Name = "to_amount")] double toAmount)
{}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question