I have an issue with postman and c# code. I have two post calls to an API that must in the end make a callback to another API (webhook).
I tried to launch the two calls through Postman and i do obtain correctly the callback response. My issue is that when I use this code I do not have any callback response but I obtain 200 message from the server I call. I have the same issue with all implementations of the http post calls I sent and get the same issue.
public static void Main(string[] args)
{
// first call
var client = new RestClient("http://xxxxxxx/emails/attachments/");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization",
"Bearer theToken");
request.AddFile("attachment",
"C:/Users/..../pdf.pdf");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
var attachmentId = response.Content;
// second call
client = new RestClient("http://xxxxxxx/emails/");
client.Timeout = -1;
request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization",
"Bearer theToken");
request.AddParameter("application/json",
"{\r\n \"subject\": \"email with attachment\",\r\n \"body\": \"Hi !!!l\\r\\n\",\r\n \"received_on\": \"2021-05-24T14:07:01.5874416+02:00\",\r\n \"author\": {\r\n \"name\": \"dvera@mymail.fr\",\r\n \"smtp_address\": \"\"\r\n },\r\n \"sender\": {\r\n \"name\": \"dvera@mymail.fr\",\r\n \"smtp_address\": \"\"\r\n },\r\n \"to\": [\r\n {\r\n \"name\": \"dvera@mymail.fr\",\r\n \"smtp_address\": \"\"\r\n }\r\n ],\r\n \"cc\": [\r\n {\r\n \"name\": \"\",\r\n \"smtp_address\": \"\"\r\n }\r\n ],\r\n \"attachments\": [\r\n " +
attachmentId + "\r\n ]\r\n}\r\n", ParameterType.RequestBody);
response = client.Execute(request);
Console.WriteLine(response.Content);
}
}
Any idea about what's going wrong ? the weird thing is that I have a 200 response for each calls i make.