NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Imports System.IO, System.Net, System.Text

Public Class GeverAPITest
Private Function getObject() As Task
Try
Dim webClient As New System.Net.WebClient
webClient.Headers("Accept") = "application/json"
webClient.Headers("Authorization") = "Basic cmFwaGFlbC5zY2h3b2I6ZGVtbzEw"

Dim DataStream As Stream = webClient.OpenRead(txt_url.Text)
Dim Reader As New StreamReader(DataStream)
Dim Response As String = Reader.ReadToEnd()

Dim outWin As New OutputWindow
outWin.lbl_output.Text = Response
outWin.Show()
Reader.Close()
Catch ex As Exception
Console.Write(ex.Message)
End Try
Return Nothing
End Function

Private Function postObject() As Task
Try
Dim url = "https://lab.onegovgever.ch/ordnungssystem/ressourcen-und-support/ict/allgemeines"
Dim request As HttpWebRequest = WebRequest.Create(url)
request.Accept = "application/json"
request.ContentType = "application/json"
request.Headers.Add("Authorization", "Basic cmFwaGFlbC5zY2h3b2I6ZGVtbzEw")
request.Method = "POST"

Dim data_str As String =
"{
""@type"": ""opengever.dossier.businesscasedossier"",
""title"": ""NewDoc via VB.Net PloneAPI"",
""responsible"": ""raphael.schwob"",
""custody_period"": 30,
""retention_period"": 10,
""archival_value"": ""unchecked""
}"

Dim byteArray As Byte() = Encoding.UTF8.GetBytes(data_str)
request.ContentLength = byteArray.Length

Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()

Dim response As WebResponse = request.GetResponse()
Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)

dataStream.Close()
response.Close()
Catch ex As Exception
Console.Write(ex)
End Try
Return Nothing
End Function

Private Function patchObject() As Task
Try
Dim url = "https://lab.onegovgever.ch/ordnungssystem/ressourcen-und-support/ict/allgemeines/dossier-189"
Dim request As HttpWebRequest = WebRequest.Create(url)
request.Accept = "application/json"
request.ContentType = "application/json"
request.Headers.Add("Authorization", "Basic cmFwaGFlbC5zY2h3b2I6ZGVtbzEw")
request.Method = "PATCH"

Dim data_str As String =
"{
""title"": ""Name changed via VB.Net PloneAPI""
}"

Dim byteArray As Byte() = Encoding.UTF8.GetBytes(data_str)
request.ContentLength = byteArray.Length

Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()

Dim response As WebResponse = request.GetResponse()
Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)

dataStream.Close()
response.Close()
Catch ex As Exception
Console.Write(ex)
End Try
Return Nothing
End Function

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btn_start.Click
getObject()
End Sub

Private Sub drop_method_SelectedIndexChanged(sender As Object, e As EventArgs) Handles drop_method.SelectedIndexChanged
Select Case drop_method.SelectedItem.ToString()
Case "GET"
grp_get.Enabled = True
txt_code.Text =
"Private Function getObject() As Task
Try
Dim webClient As New System.Net.WebClient
webClient.Headers(""Accept"") = ""application/json""
webClient.Headers(""Authorization"") = ""Basic --KEY--""

Dim DataStream As Stream = webClient.OpenRead(--URL--)
Dim Reader As New StreamReader(DataStream)
Dim Response As String = Reader.ReadToEnd()

Dim j As Object = New JavaScriptSerializer().Deserialize(Of Object)(Response)
Console.Write(j)
Console.Write(""Title:"" + j(""title""))
Reader.Close()
Catch ex As Exception
Console.Write(ex.Message)
End Try
Return Nothing
End Function"

Case "POST"
grp_get.Enabled = False
txt_code.Text =
"Private Function postObject() As Task
Try
Dim url = ""--URL--""
Dim request As HttpWebRequest = WebRequest.Create(url)
request.Accept = ""application/json""
request.ContentType = ""application/json""
request.Headers.Add(""Authorization"", ""Basic --KEY--"")
request.Method = ""POST""

Dim data_str As String =
""{
""""@type"""": """"--TYPE--"""",
""""title"""": """"--NAME--"""",
""""responsible"""": """"--PLONE-USER--"""",
""""custody_period"""": --TIME IN YRS.--,
""""retention_period"""": --TIME IN YRS.--,
""""archival_value"""": """"--VALUE--""""
}""

Dim byteArray As Byte() = Encoding.UTF8.GetBytes(data_str)
request.ContentLength = byteArray.Length

Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()

Dim response As WebResponse = request.GetResponse()
Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)

dataStream.Close()
response.Close()
Catch ex As Exception
Console.Write(ex)
End Try
Return Nothing
End Function"

Case "PATCH"
grp_get.Enabled = False
txt_code.Text =
"Private Function patchObject() As Task
Try
Dim url = ""--URL--""
Dim request As HttpWebRequest = WebRequest.Create(url)
request.Accept = ""application/json""
request.ContentType = ""application/json""
request.Headers.Add(""Authorization"", ""Basic --KEY--"")
request.Method = ""PATCH""

Dim data_str As String =
""{
""""title"""": """"--NEW NAME--""""
}""

Dim byteArray As Byte() = Encoding.UTF8.GetBytes(data_str)
request.ContentLength = byteArray.Length

Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()

Dim response As WebResponse = request.GetResponse()
Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)

dataStream.Close()
response.Close()
Catch ex As Exception
Console.Write(ex)
End Try
Return Nothing
End Function"

Case Else
txt_code.Text = ""
End Select
End Sub
End Class
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.