Hi All,
Firstly I am very new to B4A ( only installed 3 Days ago) and wish I had discovered it years ago.
I am trying to connect to a REST API that uses Oaut1 and am having trouble doing this. I have done this multiple times in VB.net but am struggling to find a way to do this in B4A. below is the code that i use in VB.net.
This is just a GET Request but I will need to do PUT and DELETE as well.
I hope someone can point me in the right direction.
Thanks in advance for any assistance and help provided it is all very appreciated.
Firstly I am very new to B4A ( only installed 3 Days ago) and wish I had discovered it years ago.
I am trying to connect to a REST API that uses Oaut1 and am having trouble doing this. I have done this multiple times in VB.net but am struggling to find a way to do this in B4A. below is the code that i use in VB.net.
B4X:
Dim oauth1 As New Chilkat.OAuth1
oauth1.ConsumerKey = "....."
oauth1.ConsumerSecret = "..."
oauth1.Token = "....."
oauth1.TokenSecret = "....."
oauth1.Realm = "1234567"
' The signature method can be HMAC-SHA1 or HMAC-SHA256
oauth1.SignatureMethod = "HMAC-SHA1"
oauth1.OauthUrl = ": https://rest.na2.netsuite.com/app/site/hosting/restlet.nl"
oauth1.OauthMethod = "GET"
' Generate an initial nonce so that Chilkat knows the desired size of the nonce.
Dim success As Boolean = oauth1.GenNonce(11)
'oauth1.AddParam("script", "665")
'oauth1.AddParam("deploy", "1")
'oauth1.AddParam("type", "getpickslipnotdispatch")
'oauth1.AddParam("recordtype", "salesorder")
Dim rest As New Chilkat.Rest
rest.AddQueryParam("script", "665")
rest.AddQueryParam("deploy", "1")
rest.AddQueryParam("type", "getpickslipnotdispatch")
rest.AddQueryParam("recordtype", "salesorder")
' Tell the REST object to use the OAuth1 object for authentication.
' Also, indicate that the OAuth authentication parameters should be query parameters
' and not located within the Authorization header.
Dim bUseQueryParams As Boolean = False
success = rest.SetAuthOAuth1(oauth1, bUseQueryParams)
' Make the initial connection (without sending a request yet) to the WooCommerce endpoint at your Wordpress blog.
Dim bTls As Boolean = True
Dim port As Integer = 443
Dim bAutoReconnect As Boolean = True
success = rest.Connect("rest.na2.netsuite.com", port, bTls, bAutoReconnect)
If (success <> True) Then
Console.WriteLine(rest.LastErrorText)
Exit Sub
End If
' Send a GET request to list orders.
' When the request is sent, the OAuth1 object's Timestamp and Nonce properties are automatically
' regenerated. Also, the OAuth1 object's OauthMethod property is automatically set to the HTTP method
' used for the request (in this case it is "GET").
Dim responseJson As String = rest.FullRequestNoBody("GET", "/app/site/hosting/restlet.nl")
If (rest.LastMethodSuccess <> True) Then
'Console.WriteLine(rest.LastErrorText)
Exit Sub
End If
This is just a GET Request but I will need to do PUT and DELETE as well.
I hope someone can point me in the right direction.
Thanks in advance for any assistance and help provided it is all very appreciated.