Hi all, I have a current request to download field collected data and pics hosted in ArcGIS Online and format in an Excel table. In the back end of Excel (VBA) have managed to connect to ArcGIS online and generate a token with the following 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=" & Me.userName_Txt.Value & "&password=" & Me.password_Txt.Value & "&client=requestip&expiration=1"
tokenHTTP.Open "POST", tokenURL, False
tokenHTTP.setRequestHeader "Content-type", "application/json"
tokenHTTP.send (tokenJSON)
Debug.Print (tokenHTTP.responseText) the response looks like this. {
"token":"hIBzdwwVbXv9k8iIZtr0LBwZ5ujSwCdTrdS6_P1XngsglCLnB2tpiV8u9W-6oMDA9Ggf6EMMd77SmXH6BPszKSGvf_oz9QTnEyt4YsSZ-nCuUDzhxW8j6oaAKET8Hk-4qBnLiXGEpuz8JifBSLwHFg..",
"expires":1541634562738,
"ssl":true
} The problem is, when I try to use this token to query a FeatureService like this Dim httpObj As Object
Set httpObj = CreateObject("MSXML2.ServerXMLHTTP")
Dim responseJSON As String
Dim featureServiceURL As String
featureServiceURL = "https://services8.arcgis.com/myagolid/arcgis/rest/services/test_points/FeatureServer/0/query?where=OBJECTID>1&outFields=*&returnHiddenFields=true&returnGeometry=true&returnExceededLimitFeatures=true&f=pgeojson&token=" & agoToken
Debug.Print ("Get Data from: " & featureServiceURL)
httpObj.Open "POST", featureServiceURL, False
httpObj.setRequestHeader "Content-type", "application/json"
httpObj.send (responseJSON)
Debug.Print (responseJSON) I get this error? {
"error" :
{
"code" : 498,
"message" : "Invalid token.",
"details" : [
"Invalid token."
]
}
} I cant work out what is going on here? Is it not returning the full length of the token? Or do I have to configure something in my ArcGIS Online account to allow access? Any help would be much appreciated Thanks James
... View more