Hi
How to pass Dynamic Parameters in body of RestSharp in asp.net c#
Thanks
Hi
How to pass Dynamic Parameters in body of RestSharp in asp.net c#
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Uday DodiyaPosted Jan 9, 2023, 4:03 AM
To pass dynamic parameters in the body of a RestSharp request in ASP.NET C#, you can use the
AddParametermethod of theRestRequestclass and set theTypeproperty toParameterType.RequestBody.Here's an example of how you could do this:
You can also add multiple parameters to the request body by using the
AddJsonBodyorAddXmlBodymethods of theRestRequestclass, depending on the format of the data you want to send.Pasang TamangPosted Jan 9, 2023, 4:07 AM
Hi
There are various ways. You can use dynamic JSON object or use class object that have matching properties with required JSON format and serialize that class object values using Newtonsoft.Json. Below is the example of using dynamic JSON object.
Regards,
Pasang