POST
|
Turns out there was not a proper certificate in place. Once fixed, everything worked as expected.
... View more
08-02-2017
10:50 AM
|
0
|
0
|
493
|
POST
|
I have created an Android app using Meteor that only has a client side (no Meteor server side). The app uses the ArcGIS REST API to obtain a token and then posts user location data to a service. The app functions as expected in development (run from meteor on Android device) but not in production (install signed APK on Android device). The POST requests do not work in production. I have tried a few different ways to implement the POST request, all of which work in development but not in production: jQuery AJAX - does not appear to use success or error functions Meteor HTTP ( Meteor.http.call ) - response is undefined ESRI-Leaflet ( L.esri.post ) - code: 500; message: Could not parse response as JSON. This could also be caused by CORS or XMLHttpRequest error.; response is null After a few straight days of trying to determine if the exact problem is in the code, a Meteor, CORS, or something else, I feel I have exhausted all avenues. I am not a CORS guru and I am not a server manager, etc so I am not completely sure how to troubleshoot. From the results listed above, it sounds like the requests are not being sent. Below is some sanitized code for the three different POST functions I have tried. "getToken_ajax" is my original and preferred function. I assume since the app works in development it should work in production but likely with some modification in the code or updates to settings/parameters on the server. However, I am unsure of what needs to change. Any thoughts? Thanks, Josh
var getToken_ajax = function() {
var tokenData = {
username: "theusername",
password: "thepassword",
f: 'json',
expiration: 60,
client: 'referer',
referer: window.location.origin
};
$.ajax({
url: "https://<address>/arcgis/tokens/generateToken",
dataType: 'json',
type: 'POST',
data: tokenData,
crossDomain: true,
success: function(data, textStatus, jqXHR) {
$(".status").empty();
$("#status").empty().append("status: " + textStatus);
$("#data").empty().append("data: " + JSON.stringify(data));
$("#jqXHR").empty().append("jqXHR: " + JSON.stringify(jqXHR));
},
error: function(data, textStatus, jqXHR) {
$(".status").empty();
$("#status").empty().append("status: " + textStatus);
$("#data").empty().append("data: " + JSON.stringify(data));
$("#jqXHR").empty().append("jqXHR: " + JSON.stringify(jqXHR));
}
});
};
var getToken_meteorhttp = function() {
var tokenData = {
headers: {
"Content-type": "application/x-www-form-urlencoded"
},
params: {
username: "theusername",
password: "thepassword",
f: 'json',
expiration: 60,
client: 'referer',
referer: window.location.origin
}
};
Meteor.http.call("POST", "https://<address>/arcgis/tokens/generateToken", tokenData,
function(error, response) {
$(".status").empty();
$("#status").empty().append("status: " + JSON.stringify(error));
$("#response").empty().append("response: " + JSON.stringify(response));
});
};
var getToken_leaflet = function() {
function serverAuth(callback) {
L.esri.post('https://<address>/arcgis/tokens/generateToken', {
username: "theusername",
password: "thepassword",
f: 'json',
expiration: 86400,
client: 'referer',
referer: window.location.origin
}, callback);
};
serverAuth(function(error, response) {
$(".status").empty();
$("#status").empty().append("status: " + JSON.stringify(error));
$("#response").empty().append("response: " + JSON.stringify(response));
});
};
... View more
07-21-2017
02:50 PM
|
0
|
1
|
995
|
POST
|
I'm building an app using AppStudio/Qt Creator that continuously collects the gps location, performs some queries on a local geodatabase, and syncs the geodatabase with server. When the app is not the active app on the phone, the app pauses. When active again, it will resume where it left off. I noticed in the Console the "state" of the app changes: qml: App State: 2 | Flag: false <---- app pauses qml: App State: 0 | Flag: true <---- app resumes Is it possible for the app to keep running when it is not the active app? Thanks, Josh
... View more
11-19-2016
12:57 PM
|
0
|
1
|
747
|
POST
|
I am trying to set up authentication for an app but I am not sure what I am trying to do is possible. The app will be used by users "who are unknown to the ArcGIS platform" so I need to implement an "app login". However, the service to be accessed will need to be private because of confidentiality concerns. From what I have read in the developer docs it sounds like this combination is not possible. I tried to put together some code to try anyhow. If what I am trying is not possible, some alternate ideas would be greatly appreciated. I assume the "easiest" route would be, since I need to keep the service private, to make the individuals using the app ArcGIS Online users. The issue is I do not know who these individuals will be and they will likely change. The "users" will be truck drivers that will carrying the devices in their trucks to record when they enter certain locations. What I have done so far: 1. Published a server with two layers (0: points, 1: polygons) which functions as expected. 2. Registered an app on developers.arcgis.com and acquired the Client ID and Client Secret. 3. Created a new role ("ThisRole") on ArcGIS Server Manager and added my username as a member (will have to change that at some point). 4. Made the service private and added "ThisRole" as the allowed role. 5. Added the code below to implement "app login". 6. Created a simple app to perform a QueryTask on a layer in the service to see if the app could acquire access. 7. Ran the app with the service public. QueryTask returned with correct query result. 8. Ran the app, multiple times, with the service private. QueryTask result was null. I have tried several variations of the code below. I am not completely sure which parameters are required and, for some, what the parameter value actually needs to be or where the value comes from. For example, I may be mixing user and app login parameters. I have been using the following resources: https://developers.arcgis.com/qt/qml/guide/use-oauth-2-0-authentication.htm https://developers.arcgis.com/authentication/accessing-arcgis-online-services/ App Code: import QtQuick 2.3 import QtQuick.Controls 1.2 import ArcGIS.Runtime 10.26 ApplicationWindow { id: appWindow width: 800 height: 600 title: "authentication" property string urlPolygonLayer: "url/to/feature/service/layer" UserCredentials { id: credentials oAuthClientInfo: OAuthClientInfo { clientId: "client_id_from_registered_app" clientSecret: "client_secret_from_registered_app" oAuthMode: Enums.OAuthModeApp } } Connections { target: ArcGISRuntime.identityManager onOAuthCodeRequired: { console.log("onOAuthCodeRequired signal") // ????? Not sure what authCode and authorizationUrl need to be. Tried a few times but no luck. // Access URL in the authorizationUrl property to obtain auth code var authCode = … // apply the auth code to the identity manager ArcGISRuntime.identityManager.setOAuthCodeForUrl(authorizationUrl, authCode) } } QueryTask { id: queryTask url: urlPolygonLayer onQueryTaskStatusChanged: { console.log("onQueryTaskStatusChanged signal") if (queryResult === null) { console.log("Query result is null.") } else { console.log("Query result length: " + queryResult.graphics.length) } } } Query { id: query where: "1=1" } Component.onCompleted: { // Add the credentials to the identity manager // ????? Not sure what "some_url" is supposed to be here. I have used "https://domain.com/arcgis/rest" ArcGISRuntime.identityManager.setCredential( credentials, some_url) queryTask.execute(query) } }
... View more
10-20-2016
12:42 PM
|
0
|
2
|
1748
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|