I have done a post URL and I get JSON format respondtext. I want to get "barcodes" starting from cell(1,1) This is what JSON response is:
"{
""status"": ""success"",
""message"": ""5 New Barcode(s) Generated for batch 5924592"",
""data"": {
""batch"": ""5924592"",
""barcodes"": [
""MN8HY6"",
""5BZZ9K"",
""9R6QKR"",
""869P8Z"",
""XK2UXZ""
]
}
}"
Here is what I have written so far on VBA excel
Dim Json As Object
Dim xmlhttp As New MSXML2.XMLHTTP60
Dim Parsed As Dictionary
Dim Item As Dictionary
'Post
xmlhttp.Open "POST", "url", False
'setting auth headers
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.setRequestHeader "Authorization", "token"
Dim Bqty As Variant
Dim bID As Variant
Bqty = Sheets("sheet1").Range("f1").Value
bID = Sheets("sheet1").Range("f4").Value
xmlhttp.send "action=" & "createBarcodes" & _
Chr(38) & "barcodes=" & Bqty & _
Chr(38) & "batch=" & bID
JsonString = xmlhttp.responseText
Set Json = JsonConverter.ParseJson(xmlhttp.responseText)
Set Parsed = JsonConverter.ParseJson(xmlhttp.responseText)
Dim i As Integer
i = 1
For Each Item In Parsed("data")
Sheets("Batch ID").Cells(i, 1).Value = Item("barcodes")
i = i + 1
Next
Please if someone can help as I have spent all day figuring this out. I am not a professional VBA developer.
Thank you