Hi
I have below code . I want if it is success then Successful message is displayed else error message or what is the return response of API
var body = new JavaScriptSerializer().Serialize(objShippingOrdr);
var client = new RestClient("htps://api.nimbuspost.com/v1/shipments");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Thanks
Amit MohantyPosted Dec 29, 2022, 6:49 AM
you can use like this also
Amit MohantyPosted Dec 29, 2022, 6:25 AM
Try this
Response class
use like below
Pasang TamangPosted Dec 29, 2022, 5:20 AM
Hi Ramco,
You should be able to read the content of your response. That is where you get to know everything. Your response will give you status with some message. You can also use try catch to catch unexpected runtime error. Please check below code for your reference. I have attached screenshot also to give you idea about how the response looks like.
Regards,
Pasang