0

I am trying to implement Facebook webhook in my .net 6 project. I have verified the webhook url but when i send test "messages" from facebook webhook.it doesnt create any file. its creating log and data text file for other messaging related tests but not with messages. Below is my code.

 var jsonData = await new StreamReader(Request.Body).ReadToEndAsync();
 _logger.LogInformation($"Received JSON: {jsonData}");
 var directoryPath = Path.Combine(_config["PathSetting:BasePath"], "Data");
 Directory.CreateDirectory(directoryPath);

 var receivedDataFilePath = Path.Combine(directoryPath, "ReceivedData.txt");
 await System.IO.File.WriteAllTextAsync(receivedDataFilePath, jsonData);

 var logFilePath = Path.Combine(directoryPath, "LogFile.txt");
 await System.IO.File.WriteAllTextAsync(logFilePath, $"{DateTime.Now}: {jsonData}\n");

 return Ok(new { success = true, message = "Message received and saved successfully" });

 

i am creating file for any json that hits that api..other tests are creating in text file..meaning facebook is hitting my route..but why am i not getting "messages" test

New contributor
Muhammad Jahangir Mustafa is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

0

Browse other questions tagged or ask your own question.