How to get template list from docusing account? - vb.net

How to retrieve all template from Docusign api using vb.net.I manage to create multiple template through docusing website, and need to retrieve list of template from account.
Regards,
Aravind

You will need to add the nuget package from https://www.nuget.org/packages/DocuSign.eSign.dll/ but this code is not for latest version.
Imports System
Imports System.Collections.Generic
Imports DocuSign.eSign.Api
Imports DocuSign.eSign.Client
Imports DocuSign.eSign.Model
Imports Microsoft.AspNetCore.MvcPrivate Sub SurroundingSub()
Dim config = New Configuration(New ApiClient(basePath))
config.AddDefaultHeader("Authorization", "Bearer " & accessToken)
Dim templatesApi As TemplatesApi = New TemplatesApi(config)
Dim options As TemplatesApi.ListTemplatesOptions = New TemplatesApi.ListTemplatesOptions()
options.searchText = "Example Signer and CC template"
Dim results As EnvelopeTemplateResults = templatesApi.ListTemplates(accountId, options)
End Sub

Related

SSIS VB.Net Script to download a file using a proxy

I am trying to write a VB.Net script to download a file from the web in a SSIS dtsx package.
I started from this, but I am having only proxy authentication errors (error 407).
I double checked the proxy, the port and the URL an they are right!
Can anyone help me please? I can't understand where the problem could be.
' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Net
Public Class ScriptMain
Public Sub Main()
Dim objWebClient As WebClient = New WebClient()
Dim objCache As New CredentialCache()
Dim strDownloadURL As String = "http://www.example.com/data.xlsx"
Dim strProxyURL As String = "myproxy.mycompany.local"
Dim intProxyPort As Integer = 1234
'Set Proxy & Credentials as a Network Domain User acc to get through the Proxy
Dim wp As WebProxy = New WebProxy(strProxyURL, intProxyPort)
objWebClient.Proxy = wp
'Download file, use Flat File Connectionstring to save the file
objWebClient.DownloadFile(strDownloadURL, "E:\MyFile.xlsx")
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
The file of strDownloadURL is accessible by browser and doesn't need any form of authentication. Anyone can access it by a web browser.

How to create global obects in vb.net

I'm using visual studio 2015.
I'm clearly missing some things...
I want to create a global filestream and stream writer.
Dim wFile As System.IO.FileStream = New FileStream _
("C:\inetpub\wwwroot\SummitMap1Local\Labels\BufferedData.txt", FileMode.Append)
Dim sw As New StreamWriter(wFile)
This works fine. BUT I need to access it globally. Ideally the code would be in its own .aspx file and the wFile and sw objects could be used in a different .aspx file.
Thanks
(odd that I need to edit my original post to add new info)
I am now trying to add a class based on info from MSDN. It's not working. Code -
Imports System
Imports System.IO
Imports System.Text
Public Class test
Public Shared Sub CreateFileStream()
Dim fs As FileStream = New FileStream("C:\inetpub\wwwroot\SummitMap1Local\Labels\BufferedData.txt", FileMode.Append
End Sub
End Class
Then trying to use the class in a function -
Protected Function bufferList(ByVal testData As String) As String
Try
Dim sw As New StreamWriter(fs)
sw.WriteLine(testData)
End Try
End Function
I get an error on 'Dim sw As New StreamWriter(fs)' fs is not declared. It may be inaccessible due to it's protection level
I've tried calling it with test.fs, but test does not have an fs property.

Exceptions using Oauth2 with Google Calendar API and vb.Net

i'm not able to connect to the google calendar api via oauth2. I've downloaded the *.json file which includes my cliend-id and my cliend secret and use google's code example
'Copyright 2013 Google Inc
'Licensed under the Apache License, Version 2.0(the "License");
'you may not use this file except in compliance with the License.
'You may obtain a copy of the License at
' http://www.apache.org/licenses/LICENSE-2.0
'Unless required by applicable law or agreed to in writing, software
'distributed under the License is distributed on an "AS IS" BASIS,
'WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
'See the License for the specific language governing permissions and
'limitations under the License.
Imports System.Collections.Generic
Imports System.IO
Imports System.Threading
Imports Google.Apis.Calendar.v3
Imports Google.Apis.Calendar.v3.Data
Imports Google.Apis.Calendar.v3.EventsResource
Imports Google.Apis.Services
Imports Google.Apis.Auth.OAuth2
Imports Google.Apis.Util.Store
''' <summary>
''' An sample for the Calendar API which displays a list of calendars and events in the first calendar.
''' https://developers.google.com/google-apps/calendar/
''' </summary>
Module Program
'' Calendar scopes which is initialized on the main method.
Dim scopes As IList(Of String) = New List(Of String)()
'' Calendar service.
Dim service As CalendarService
Sub Main()
' Add the calendar specific scope to the scopes list.
Dim scopes As IList(Of String) = New List(Of String)()
scopes.Add(CalendarService.Scope.Calendar)
' Display the header and initialize the sample.
Console.WriteLine("Google.Apis.Calendar.v3 Sample")
Console.WriteLine("==============================")
dim credential As UserCredential
Using stream As New FileStream("c:/temp/client_secrets.json", FileMode.Open, FileAccess.Read)
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets, scopes, "user", CancellationToken.None,
New FileDataStore("Calendar.VB.Sample")).Result
End Using
' Create the calendar service using an initializer instance
Dim initializer As New BaseClientService.Initializer()
initializer.HttpClientInitializer = credential
initializer.ApplicationName = "VB.NET Calendar Sample"
service = New CalendarService(initializer)
' Fetch the list of calendar list
Dim list As IList(Of CalendarListEntry) = service.CalendarList.List().Execute().Items()
' Display all calendars
DisplayList(list)
For Each calendar As Data.CalendarListEntry In list
' Display calendar's events
DisplayFirstCalendarEvents(calendar)
Next
Console.WriteLine("Press any key to continue...")
Console.ReadKey()
End Sub
end class
I get an mscorelib-exception in line GoogleWebAuthorizationBroker.AuthorizeAsync(...
I cecked if the "stream" variable get the id and the secret, but everything is fine except the authentication.
Do anybody have an idea what i did wrong or what i should try?
Which "user" do i have to insert? (I used the ******#developer.gserviceaccount.com)
i also tried this version of the code for accessing the youtube api
Private Async Function GetGredentials() As Task
Try
AddToLog("Begin: GetCredentials")
'
' ClientId and ClientSecret are found in your client_secret_*****.apps.googleusercontent.com.json file downloaded from
' the Google Developers Console ( https://console.developers.google.com).
' This sample shows the ClientID and ClientSecret in the source code.
' Other samples in the sample library show how to read the Client Secrets from the client_secret_*****.apps.googleusercontent.com.json file.
'
Dim scopes As IList(Of String) = New List(Of String)()
scopes.Add(Google.Apis.Calendar.v3.CalendarService.Scope.Calendar)
OAUth2Credential = Await GoogleWebAuthorizationBroker.AuthorizeAsync( _
New ClientSecrets With {.ClientId = "242596777308-jmpe9cq9lvr23kmgt7bgsac6ogf620k8.apps.googleusercontent.com", _
.ClientSecret = "beymodgzMv9kenB8ds2R5Bb_"}, _
scopes, "me", CancellationToken.None)
AddToLog("End: GetCredentials")
If OAUth2Credential IsNot Nothing Then
If OAUth2Credential.Token IsNot Nothing Then
AddToLog(String.Concat("Token Issued: ", OAUth2Credential.Token.Issued))
End If
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Google Authorization")
End
End Try
End Function
the used id and secret are copied directly from google's api console. The code throws now an exception "application not found"
The exception stacktrace is:
bei Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
bei Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
bei Microsoft.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
bei YouTube_API_V3_Demo.Main.VB$StateMachine_1_GetGredentials.MoveNext() in C:\Users\Michael\Downloads\Sample\YouTube_API_V3_Demo\YouTube_API_V3_Demo\Main.vb:Zeile 202.
I think that something is wrong with the oauth2 authentication, but what??
What do i have to insert in the "user" parameter?
Michael

FilePath as a URL, Visual Basic Desktop App

I am using the code below to bind data from a XML file in my PC. It works fine when using a local PC filePath, but when I change the location of the XML filePath to an URL which is listed below. it simply doesn't work. I made this xml file public in my onedrive but still doen´t work. Do I need to download the file and then readXML?
Many Thanks,
Imports System
Imports System.IO
Imports System.Net
Imports System.Xml
Public Class NasgoLive
Private Sub RefreshButton_Click(sender As Object, e As EventArgs) Handles RefreshButton.Click, RefreshButton.Click
MessageBox.Show("Done")
Me.BackColor = Color.FloralWhite
Dim filePath As String = "Complete path where you saved the XML"
AuthorsDataSet.ReadXml("https://onedrive.live.com/? cid=42FE4354E1EDA2AE&id=42FE4354E1EDA2AE%21674")
alliancehorizonvalue.DataSource = AuthorsDataSet
alliancehorizonvalue.DataMember = "alliancehorizon"
arcticovalue.DataSource = AuthorsDataSet
arcticovalue.DataMember = "arctico"
You need to download the file first. DataSet.ReadXml supports just a file name, not url.
You could download the file with a WebClient (not tested):
byte[] data;
using (WebClient client = new WebClient()) {
data = client.DownloadData("https://onedrive.live.com/?cid=42FE4354E1EDA2AE&id=42FE4354E1EDA2AE!674");
}
File.WriteAllBytes(#"c:\myfile.xml", data);
EDIT:
For downloading you need to use OneDrive API

Missing Carriage Return in Downloaded Email Attachment ImapX

Here is my code:
#Region "Imports"
Imports System.Text.RegularExpressions
Imports System.Text
Imports Microsoft.VisualBasic.CallType
Imports ImapX
Imports System.Runtime.CompilerServices
Imports System.Security.Authentication
Imports System.IO
Imports ml = System.Net.Mail
Imports System.Net
Imports ImapX.Enums
Imports ImapX.Constants
Imports System.Security.Authentication.SslProtocols
#End Region
Module Module1
Sub Main()
Dim _messages As List(Of ImapX.Message)
Using MyImapClient = New ImapX.ImapClient
With MyImapClient
.Host = ImapServer
.Port = Port
.SslProtocol = Ssl3 Or Tls
.ValidateServerCertificate = True
.Credentials = New ImapX.Authentication.PlainCredentials(UserName, Password)
Dim IsConnected As Boolean = .Connect
.Login()
.Behavior.AutoDownloadBodyOnAccess = False
.Behavior.AutoPopulateFolderMessages = False
.Behavior.MessageFetchMode = MessageFetchMode.Full
.Behavior.ExamineFolders = False
.Behavior.RequestedHeaders = {MessageHeader.From, MessageHeader.[Date], MessageHeader.Subject, MessageHeader.ContentType, MessageHeader.Importance}
'Dim IsInboxSelected As Boolean = .SelectFolder(.Folders.Inbox.Name)
'Dim IsInboxSelected As Boolean = .Folders(.Folders.Inbox.Name).[Select]()
End With
Dim MyFolder As Folder = MyImapClient.Folders.Inbox
_messages = MyFolder.Search().OrderBy(Function(n) n.[Date]).ToList()
_messages.ForEach(Sub(n) n.Download(MessageFetchMode.Full))
_messages.ForEach(Sub(n) n.Download(MessageFetchMode.Full))
End Using
Dim MyAttachment As ImapX.Attachment = _messages.First.Attachments.First
MyAttachment.Download()
Dim FolderPath As String = "C:\Users\AAA\Downloads\"
Dim LocalFileName As String = "1212.txt"
MyAttachment.Save(FolderPath, LocalFileName)
End Sub
End Module
The code works without issue--it connects to the imap server, downloads the first attachment of the first email, which happens to be a .txt file, so I'm saving it as such.
The problem is that the contents of the file is prepended with " * 2 FETCH (" and is followed by " UID 45", and all carriage returns are removed from the file.
Can you please assist? Thanks,
My guess is the CRLF's ( Carriage Return Line Feeds ) are not the format whatever you're viewing the download in is looking for. I would look at your attachment using something like NotePad++ and make sure you're showing Carriage Returns. If all you see are cr's and you're viewing the file in something looking for crlf's then they will get ignored.
Another thing to look at is what default encoding is your .download call using and what encoding is the original attachment in.