Excel vba request a token from Rest API appears to be 106 characters shorter than token generated by arcgis online query tools

1676
0
08-20-2019 01:39 PM
Larry
by
New Contributor III

I am trying create a VBA tool in Excel to insert data into a AGOL Feature layer. When I request a token via VBA it ends with .. and is 106 characters shorter than the token generated by the AGOL query tool. when I try to use the token I request I get and "invalid token" error. But if I copy the AGOL generated token and paste it into my code my query works fine. It looks like the VBA requested token is cut off.

Anyone else run into this?

Thanks

Larry

A snippet of my code:

Dim tokenHTTP As Object
Set tokenHTTP = CreateObject("MSXML2.ServerXMLHTTP")
Dim tokenJSON As String
Dim tokenURL As String
tokenURL = "https://www.arcgis.com/sharing/rest/generateToken?f=json&username=MyuserName&password=MyPassword&client=requestip&expiration=1"
 
tokenHTTP.Open "POST", tokenURL, False
tokenHTTP.setRequestHeader "Content-type", "application/json"
tokenHTTP.send (tokenJSON)

Debug.Print tokenHTTP.responseText

0 Kudos
0 Replies