T
tomasheq84
Guest
I'm trying to move from Visual Basic for Excel to Visual Basic in Visual Studio 2017 with Windows Forms.
On Excel I was able to prepare simple app to download payloads via WebAPI using:
I can't find anything on the internet that would be clear enough for me (maybe I'm not searching in proper places, but I spent a few good hours trying), so I thought I'll ask.
Code:
Sub GetJSON()
Dim oHTTP, jsonObj As Object
Order = Form1.TextBox1.Value
Set oHTTP = CreateObject("MSXML2.ServerXMLHTTP")
URL = "https://www.courierwebsite.com/Trackings?$filter=(ShipmentId eq '" & Order & "')"
oHTTP.Open "GET", URL, False
oHTTP.setRequestHeader "Content-type", "application/json"
oHTTP.setRequestHeader "Authorization", "Basic " & "[encoded_user_+_password]"
oHTTP.send
result = oHTTP.responseText
Set jsonObj = ParseJson(result)
For Each Item In jsonObj
Form1.Label1.Value = Item("TrackingNumber")
Next
End Sub
and now I'd like to do the same on VB in Visual Studio 2017 with Windows Forms. Is it even possible? I'd need it with authentication as well, please.
I understand it the best when I can see what code does step by step - that helps me in learning something new.
If you could please tell me step by step what I need to do on VB2017 to achieve the same result (tracking number as the message) or if it is even possible?
Or maybe there is even easier way of achieving my result? (My next thing to learn is JavaScript - so maybe in that? )
Continue reading...
On Excel I was able to prepare simple app to download payloads via WebAPI using:
JsonConverter module,
Reference of Windows Scripting Runtime
JSON looking like this:
{"ShipmentId": "Order123456",
"TrackingNumber": "98431984651"
},
and code below
I can't find anything on the internet that would be clear enough for me (maybe I'm not searching in proper places, but I spent a few good hours trying), so I thought I'll ask.
Code:
Sub GetJSON()
Dim oHTTP, jsonObj As Object
Order = Form1.TextBox1.Value
Set oHTTP = CreateObject("MSXML2.ServerXMLHTTP")
URL = "https://www.courierwebsite.com/Trackings?$filter=(ShipmentId eq '" & Order & "')"
oHTTP.Open "GET", URL, False
oHTTP.setRequestHeader "Content-type", "application/json"
oHTTP.setRequestHeader "Authorization", "Basic " & "[encoded_user_+_password]"
oHTTP.send
result = oHTTP.responseText
Set jsonObj = ParseJson(result)
For Each Item In jsonObj
Form1.Label1.Value = Item("TrackingNumber")
Next
End Sub
and now I'd like to do the same on VB in Visual Studio 2017 with Windows Forms. Is it even possible? I'd need it with authentication as well, please.
I understand it the best when I can see what code does step by step - that helps me in learning something new.
If you could please tell me step by step what I need to do on VB2017 to achieve the same result (tracking number as the message) or if it is even possible?
Or maybe there is even easier way of achieving my result? (My next thing to learn is JavaScript - so maybe in that? )
Continue reading...