Hi
I have below response returned . I want to save this information in Sql Database.
{
"status": 1,
"uuid": "fcfc0321-838a-4014-b88f-3e31f57fe331",
"message": "EWB Generated",
"alert": "Total invoice value is more than the sum of total assessible value and tax values, ",
"validUpto": "18/04/2024 11:59:00 PM",
"ewayBillNo": 121010463262,
"ewayBillDate": "17/04/2024 05:04:00 PM",
"EWayBillPdfUrl": "/~fnsjdjszvw/a/eway-bill/fcfc0321-838a-4014-b88f-3e31f57fe331/ewb/.pdf/",
"EWayBillQrCodeUrl": "/~fnsjdjszvw/a/ewaybill/fcfc0321-838a-4014-b88f-3e31f57fe331/qr-code/",
"Distance": "100"
}
Thanks
Ashutosh SinghPosted Apr 19, 2024, 11:07 AM
To save the provided JSON response into a SQL database using .NET Core, you'll need to follow these steps:
Here's a basic example:
Make sure you have your database connection configured in your
appsettings.jsonorappsettings.Development.jsonif you're using Entity Framework Core. You'll also need to register your DbContext and any services you're using in yourStartup.csfile.This example assumes you're using Entity Framework Core for database access and Newtonsoft.Json for JSON serialization/deserialization.
Jignesh KumarPosted Apr 19, 2024, 3:30 AM
Hello Ramco,
Please use this way,
If you are using like IRestResponse response = client.Execute(request); then you need to check statuscode with api response sucess code and then need to convert response.content to string then it will wotk for you.
Ramco RamcoPosted Apr 18, 2024, 4:22 PM
Hi All
I have below code but it is giving error - Argument 1 : Cannot convert from RestSharp.IrestResponse to string.
Thanks
Vishal YelvePosted Apr 18, 2024, 5:52 AM
Hi Ramco,
Both solutions are provided to you. Jaimin Shethiya shared code using an entity framework and Jignesh Kumar has shared ADO.Net.
Do let us know if you want more help :)
Jignesh KumarPosted Apr 18, 2024, 3:58 AM
Hello Ramco,
You need to create table if you have not created. please creaete table as below,
Then you need to deserialize your api respone in C# and you can store in above table,
Jaimin ShethiyaPosted Apr 18, 2024, 3:56 AM
Hello Ramco,
Please refer below code.
Thanks