How to resolve 400 error code, "one or more validation error occurred".

Emeka Okoye 126 Reputation points
2022-12-12T03:14:28.07+00:00

Hello,
I am trying to fix a payment Api using visual studio c#, but I am getting 400 error message, it says that one or more validation error occurred.
please what could be my mistake?
I tried running the code in postman, and it worked fine.
Below is my code sample:

public class Root  
        {            
            public string amount { get; set; }  
            public string email { get; set; }  
            public string currency { get; set; }  
            public string initiate_type { get; set; }  
            public string transaction_ref { get; set; }  
            public string callback_url { get; set; }  
        }  
  
  
  
var client = new RestClient("https://sandbox-api-d.squadco.com/transaction/initiate");  
  
            var rootObj = new Root  
                            {  
                                amount = "1000",  
                                email = EmailV,  
                                currency = "NGN",  
                                initiate_type = "inline",  
                                transaction_ref = "213445RT",  
                                callback_url = "https://samplesite.com"                          
                            };  
            //serialization using Newtonsoft JSON   
            string JsonBody = JsonConvert.SerializeObject(rootObj);  
  
            var request = new RestRequest();  
            request.Method = Method.Post;  
            request.AddHeader("Authorization", "sandbox_sk_3fae7c45922315aa8cb2a16db028f50a596d5fbdf351");  
            request.AddHeader("Content-Type", "application/json");  
            request.AddParameter("application/json", JsonBody, ParameterType.RequestBody);  
            RestResponse response = client.Execute(request);  
  
Developer technologies | C#
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.