0

Net based application using Web api and angularjs. I am trying to integrate payment API's. The post variables can be accessed on the redirect URL.

I am able to receive in asp.net as below.

 protected void Page_Load(object sender, EventArgs e)
        {
            string order_id = Request.Form["order_id"];
            string transaction_id = Request.Form["transaction_id"];
        }

I want to receive parameters in Webapi2. Is there any way i can write above piece of code in api? Thanks for your help.

1 Answer 1

1

You can post your data from AngularJs app to Web API using the $http.post method.

var data = {
    orderId: your_order_id,
    transactionId: your_transactio_id
};

$http
    .post("/api/token", data)
    .then(onSuccess, onError);

If you are passing data in post inside body, you should be able to receive the data using

public bool Post(PostParameters parameters)
{
    var orderId = parameters.OrderId;
    var transactionId = parameters.TransactionId;
}        

Where PostParamaters is just a plain class with the properties you want to pass. Of course, your data types can be different.

public class PostParameters
{
    public int OrderId { get; set; }
    public string TransactionId { get; set; }
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.