Hi
I am getting below error -
C#
{"status":false,"message":"awb is required\n"}C#
var awb = "321896356723";
var client = new RestClient("htps://api.nimbuspost.com/v1/shipments/cancel");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
var body = $@"{{ ""awb"": [ ""{awb} ""]}}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);Thanks

Pasang TamangRank #449 · 5.6K reputationPosted Jan 12, 2023, 1:56 AM EST
Hi,
Looking into your code, it looks string formation of body is not correct. Please try by replacing your body formation code with below code.
var body = $"{{\"awb\": \"{awb}\"}}";Regards,
Pasang
Vishal JoshiRank #377 · 6.7K reputationPosted Jan 12, 2023, 2:06 AM EST
Hello
You should try using JSONConvert from JsonNewtonsoft. try below code.
var awb = "321896356723"; var client = new RestClient("htps://api.nimbuspost.com/v1/shipments/cancel"); client.Timeout = -1; var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); var body = JsonConvert.SerializeObject(new {$@"{{ ""awb"": [ ""{awb} ""]}}"}); request.AddParameter("application/json", body, ParameterType.RequestBody); IRestResponse response = client.Execute(request);Thanks