Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add vb template #7

Merged
merged 1 commit into from

3 participants

@kfrancis

No description provided.

@kuba-kubula kuba-kubula was assigned
@kfrancis

@kuba-kubula Any idea when this might get pulled in? I can work on Java next, but I'd like to be "clean slate" if possible.

@Almad
Owner

@kfrancis Sorry about that; we are cleaning up some edges around current examples, but we'll put it in in a day or two.

Thanks for your patience!

@kuba-kubula kuba-kubula merged commit d4e3055 into apiaryio:master
@kuba-kubula
Owner

Thank you @kfrancis, will be at Apiary live in a moment, or two.

@kuba-kubula
Owner

@kfrancis Just a small question: Why are you replacing " with ' ? Is this because VB does not support \" syntax, or ? If VB supports \", can I use it instead? Because Apiary does not want to manipulate the @body at all...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 30, 2013
  1. @kfrancis

    Add vb template

    kfrancis authored
This page is out of date. Refresh to see the latest.
Showing with 30 additions and 0 deletions.
  1. +30 −0 vb.html
View
30 vb.html
@@ -0,0 +1,30 @@
+<section name="vb" class="vb">
+ <p class="ioDesc">Request</p>
+ <pre class="incoming"><code class="language-vb">
+Dim request = TryCast(System.Net.WebRequest.Create("<%= @apiUrl %><%= @url %>"), System.Net.HttpWebRequest)
+request.Method = "<%= @method.toUpperCase() %>"
+<% if @contentType: %>
+request.ContentType = "<%= @contentType %>"
+<% end %>
+<% if @headers: %>
+<% for header, value of @headers: %>request.Headers.Add(<%= @helpers.escape header %>, <%= @helpers.escape value %>)
+<% end %><% end %>
+<% if @helpers.isNotEmpty @body: %>
+ <% if @method.toUpperCase() is 'POST' or @method.toUpperCase() is 'PUT' or @method.toUpperCase() is 'DELETE': %>
+Using writer = New System.IO.StreamWriter(request.GetRequestStream())
+ Dim byteArray As Byte() = System.Text.Encoding.UTF8.GetBytes("<%= @body.replace(/"/g, "'") %>")
+ request.ContentLength = byteArray.Length
+ writer.Write(byteArray)
+ writer.Close()
+End Using
+ <% end %>
+ <% else: %>
+ request.ContentLength = 0
+<% end %>
+Dim responseContent As String
+Using response = TryCast(request.GetResponse(), System.Net.HttpWebResponse)
+ Using reader = New System.IO.StreamReader(response.GetResponseStream())
+ responseContent = reader.ReadToEnd()
+ End Using
+End Using
+</code></pre></section>
Something went wrong with that request. Please try again.