Hi
How to retreive Token value i.e data from the below response.
{"status":true,"data":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2NzE1MTcxOTEsImp0aSI6IlM3OXNtbzlSWGJVdDlUaVJHT2RhRWJGVFBVbGFGclJaSTJ3WnMzNGpsRk09IiwibmJmIjoxNjcxNTE3MTkxLCJleHAiOjE2NzE1Mjc5OTEsImRhdGEiOnsidXNlcl9pZCI6IjQ3MDYyIiwicGFyZW50X2lkIjoiMCJ9fQ.xslY3b3XLJcoOJJ7SxISYCRg-k4bINrshpH6YLJvGfP_7bO4HCg1ccVkbkf7vE2895dmO2B3BQ9ATMFoXOMuXw"}
Thanks
Deepak TewatiaPosted Dec 20, 2022, 6:47 AM
Hi Ramco,
We have two solution to solve this problem:
Solution-1
Parse the response string into a JSON object using a JSON parsing library such as Newtonsoft.Json. You can do this by calling the JsonConvert.DeserializeObject method and passing in the response string as the argument. This will give you a dynamic object that you can access the properties of.
Now access the "data" property of the dynamic object using dot notation.
Now, You can now use the token variable to access the token value.
Solution-2
Define a class to hold the data in the response, and use a JSON deserializer to deserialize the response string into an instance of that class. This can be more efficient and easier to maintain than using a dynamic object.
Thanks
Sachin SinghPosted Dec 20, 2022, 6:32 AM