Created
August 17, 2011 09:54
-
-
Save sharpred/1151233 to your computer and use it in GitHub Desktop.
Simple console app that posts a form to a drupal 6 service to return a view in JSON format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports Microsoft.Http | |
Imports Microsoft.Http.HttpClient | |
Imports Microsoft.Http.HttpMethodExtensions | |
Imports Newtonsoft.Json | |
Imports Newtonsoft.Json.Converters | |
Imports System.Net | |
Imports System.Xml | |
Imports System.IO | |
Imports System.Text | |
Module Module1 | |
Dim output As String | |
Sub Main() | |
Try | |
Dim http As New HttpClient(My.Settings.myURL) | |
Dim drupalform As New DrupalForm | |
Dim form As HttpMultipartMimeForm = drupalform.create("view", False, True) | |
Dim response As HttpResponseMessage = http.Post("/services/json", form.CreateHttpContent) | |
response.EnsureStatusIsSuccessful() | |
output = response.Content.ReadAsString | |
Dim sw As New StreamWriter("node_out.json") | |
'uncomment these to lose the crappiness at the start of the json output | |
'REMEMBER to write out newoutput to file instead of output | |
'Dim replacementstring As String = "#error" & """: false, """ & "#data" | |
'Dim newoutput As String = output.Replace(replacementstring, "content") | |
Console.WriteLine(output) | |
sw.Write(output) | |
sw.Flush() | |
sw.Close() | |
Catch ex As Exception | |
Console.WriteLine(ex.Message & " " & output) | |
End Try | |
End Sub | |
End Module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment