My Entity Class
namespace Entities
{
public class Myclass
{
public class Payee
{
public string name { get; set; }
public string accountNumber { get; set; }
}
public class Payer
{
public string bankProfileId { get; set; }
public string accountNumber { get; set; }
}
public Payer payer { get; set; }
public Payee payee { get; set; }
public string transferMode { get; set; }
public string transferAmount { get; set; }
public string externalRef { get; set; }
public string latitude { get; set; }
public string longitude { get; set; }
public string remarks { get; set; }
public string alertEmail { get; set; }
}
}
i tried this but not worked
Note*: I should not use below method give me an alternative either list or something.
var requestBody = new
{
payer = new
{
bankProfileId = "0",
accountNumber = "9999999999"
},
payee = new
{
name = "ABC ZYX",
accountNumber = "538787667671678"
},
transferMode = "CREDITCARD",
transferAmount = "5.00",
externalRef = "BILLPAY1",
latitude = "20.**36",
longitude = "78.**28",
remarks = "Credit Card BILL",
alertEmail = ""
};
I need to pass this to request body by adding it to JObject object =new jObject();
i am unable to do it pls help me
i tried object.Add(requestbody); but none works for me
once the request object saved in the database i need to show my request object like this in respected column
{
"payer" : {
"bankProfileId" : "0",
"accountNumber" : "9999999999"
},
"payee" : {
"name" : "ABC ZYX",
"accountNumber" : "538787667671678"
},
"transferMode" : "CREDITCARD",
"transferAmount" : "5.00",
"externalRef" : "BILLPAY1",
"latitude" : "20.**36",
"longitude" : "78.**28",
"remarks" : "Credit Card BILL",
"alertEmail" : ""
}
Amit MohantyPosted Jun 15, 2023, 11:29 AM
try this
Tuhin PaulPosted Jun 16, 2023, 2:17 AM
we define the Myclass entity class with its nested classes (Payer and Payee) to match the structure of your JSON object. We then create an instance of Myclass and populate its properties. We use JsonConvert.SerializeObject method from the Newtonsoft.Json namespace to serialize the myClass instance into a JSON string stored in requestBodyString.
Amit MohantyPosted Jun 15, 2023, 11:40 AM
If you use the previous code then no need to use entity class. But if you want to use your existing Myclass entity class to create the request body:
Jaya PrakashPosted Jun 15, 2023, 11:33 AM
Hi @Amit
Should I need to use my entitiy class