Dear all,
In Visual Basic I have the code that I can get the company details by entering their VATnumber. Now the result I am getting is in 1 big json string. Now I have heard that VATlayer also can work with a JSONP Callbacks, this however, I can't seem to figure out how to put in the code so, I can get each result separated. That I can get for example the company name in a string, that I can use thru out the porgram.
Can anyone please help me with this?
The code I have is;
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim URLString = "http://apilayer.net/api/validate&vat_number=GB864438791"
Try
'Create the initial request
Dim Request As HttpWebRequest = HttpWebRequest.Create(URLString)
Request.Proxy = Nothing 'Speeds up the request by setting the proxy to nothing
Request.UserAgent = "Test"
'Create response and reader
Dim Response As HttpWebResponse = Request.GetResponse
Dim ResponseStream As System.IO.Stream = Response.GetResponseStream
'Create a new streamreader
Dim StreamReader As New System.IO.StreamReader(ResponseStream)
Dim Data As String = StreamReader.ReadToEnd
UrlResponseText.Text = Data
StreamReader.Close()
Catch ex As Exception
MsgBox("Improper Input")
GoURL.Text = Nothing
End Try
End Sub
The the result is shown like;
Result from streamreader;
'{"valid":true,"database":"ok","format_valid":true,"query":"GB864438791","country_code":"GB","vat_number":"864438791","company_name":"EXERTIS (UK) LTD","company_address":"TECHNOLOGY HOUSE\nMAGNESIUM WAY\nHAPTON\nBURNLEY\n\nBB12 7BF"}
An I would like to see that I can assign all the result value to separated strings.
Thanks,
Hans
P.s.
This VAT layer requires a key to enter in the string. So this URL will not work. Like this. But with key you get the below shown result,
What I have tried:
I have search the internet and tried using
New JavaScriptSerializer().Deserialize(Of List(Of Object))(Data)
.