I generated an API call using postman, it worked perfect in Postman, but when I copied the generated code to C# environment it show no response, no error message. below is my code
var client = new RestClient("https://api.wallets.africa/transfer/bank/account");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer xxxxxxxx ");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "__cfduid=d1d00b54377d696360fab484b6a92bb4b1591788299");
request.AddParameter("application/json", "{\r\n\"SecretKey\": \"xxxxxxxxx\",\r\n\"BankCode\": \"101\",\r\n\"AccountNumber\": \"Acc No\",\r\n\"AccountName\": \"Acc name\",\r\n\"TransactionReference\": \"9821358052\",\r\n\"Amount\": 600.0,\r\n\"Narration\": \"Secure Lot\"\r\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
I stated that I generated the code using Postman code creator. It worked well in postman environment but when I copied the code to c# environment it returned null and no error message.
I think I've gotten a fix, I moved the code out of local host to a remote host and it worked fine. I don't know what may cause it not run on local host.
Member
53 Points
203 Posts
Post request worked in Postman but would not work in C#
Jun 14, 2020 03:38 AM|Enzyme|LINK
I generated an API call using postman, it worked perfect in Postman, but when I copied the generated code to C# environment it show no response, no error message. below is my code
please who knows what could be the issue.
Contributor
5961 Points
2466 Posts
Re: Post request worked in Postman but would not work in C#
Jun 14, 2020 04:18 AM|KathyW|LINK
Did you try using postman's code snippet creator?
When you have code working in postman, use the code snippet generator: https://learning.postman.com/docs/postman/sending-api-requests/generate-code-snippets/
For its C# results, it lists the RestSharp library as needed: http://restsharp.org/
Member
53 Points
203 Posts
Re: Post request worked in Postman but would not work in C#
Jun 14, 2020 08:25 AM|Enzyme|LINK
Contributor
5961 Points
2466 Posts
Re: Post request worked in Postman but would not work in C#
Jun 14, 2020 02:46 PM|KathyW|LINK
Did you use the ReSharp library? Read my earlier message.
Member
53 Points
203 Posts
Re: Post request worked in Postman but would not work in C#
Jun 14, 2020 04:02 PM|Enzyme|LINK