My problem is that I am trying to call a workflow from a visual studio webform using vb.net code. I tried using both process.start(workflowurl) and a hyperlink using the workflow url. Both of those approches are a “Get” call, while my workflow is to allow downloading a file using an ftp node and a response node, which needs to be a “Post” request. Does not work. I also tried the following code using httpclient and it does not work. Do you have a way to call an ftp workflow from a webform using vb. net code? Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Page.RegisterAsyncTask(New PageAsyncTask(AddressOf MyAsyncMethod))
End Sub
Private Async Function MyAsyncMethod() As Task
'Dim webhookUrl As String = "http://localhost:5678/webhook-test/823f20b4-f8fd-4736-b257-d9418dccffd8" ' Replace with your actual webhook URL
Dim webhookUrl As String = "https://silly-eel-99.hooks.n8n.cloud/webhook/fbcd3019-1603-4a1c-8f41-941bfb55387e"
'Dim jsonPayload As String = "{""name"": ""John Doe"", ""email"": ""[email protected]""}" ' Example JSON data to send
Using httpClient As New HttpClient()
Try
'Dim content As New StringContent(jsonPayload, Encoding.UTF8, "application/json") ' Set content type to JSON
'Dim response As HttpResponseMessage = Await httpClient.PostAsync(webhookUrl, Content) ' Make the POST request
Dim response As HttpResponseMessage = Await httpClient.GetAsync(webhookUrl) ' Make the POST request
If response.IsSuccessStatusCode Then
' Workflow triggered successfully
Console.WriteLine("n8n workflow triggered successfully!")
Else
' Handle potential errors (e.g., incorrect URL, network issues)
Console.WriteLine($"Error triggering n8n workflow: {response.StatusCode} - {Await response.Content.ReadAsStringAsync()}")
End If
Catch ex As Exception
' Handle any exceptions during the HTTP request
Console.WriteLine($"An error occurred: {ex.Message}")
End Try
End Using
Await Task.Delay(10000) ' Example delay
End Function