POST
|
I tried your script. It worked on the four features that where in the feature layer. I tested it a little bit extra by adding a few features and trying it again. Now when the service has ~10 featueres I get the same error again (I changed nothing in the code. It is the exact same script, but different amount of features). I run into this problem outside this example aswell in different projects.
... View more
03-26-2019
08:59 AM
|
0
|
0
|
1584
|
POST
|
Encountered trouble today trying to query a hosted feature service and sending the results as new features to an identical (same fields/configuration) hosted feature service using Python (requests). For the sake of this example, I reduced my code that produces the error to the example below. import json
url = r"https://services9.arcgis.com/ty0YDnowzprP81CR/ArcGIS/rest/services/testlayer/FeatureServer/0"
url_query = r"https://services9.arcgis.com/ty0YDnowzprP81CR/ArcGIS/rest/services/testlayer/FeatureServer/0/query"
url_token = r"https://www.arcgis.com/sharing/generateToken"
referer = r"https://www.arcgis.com/"
# query from featureservice 1
token_endpoint = r"https://www.arcgis.com/sharing/generateToken"
querystring = {"f": "pjson",
"client": "referer",
"referer": referer,
"expiration": "60",
"username": "<username>",
"password": "<password>"}
response = requests.post(token_endpoint, data=querystring).json()
token = response["token"]
feature_querystring = {"where": "1=1",
"objectIds": "",
"outFields": "*",
"returnGeometry": "true",
"f": "json",
"token": str(token)}
response_featuredata = requests.request("GET", url_query, params=feature_querystring)
response_featuredata_dict = response_featuredata.json()
features = response_featuredata_dict["features"]
# copy to featureservice 2
add_features_url = r"https://services9.arcgis.com/ty0YDnowzprP81CR/arcgis/rest/services/testlayer2/FeatureServer/0/addFeatures"
params = {
"features": json.dumps(features),
"token": token,
"f": "pjson"
}
response = requests.post(url=add_features_url, params=params)
print(response)
print(response.text) The above code results in the following repsonse: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>404 - File or directory not found.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>404 - File or directory not found.</h2>
<h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
</fieldset></div>
</div>
</body>
</html>
Which is weird, because when I try to manually insert the features into the addFeatures-endpoint via the browser, everything works just fine. Something else I noticed; when I change: params = {
"features": json.dumps(features),
"token": token,
"f": "pjson"
} into: params = {
"features": json.dumps(features[0]),
"token": token,
"f": "pjson"
} The code works fine (but only sends the first of the list of features to the endpoint). Does anyone have an idea about what i'm doing wrong? I'm guessing it has something to do with the way the dict/json is encoded before sending it. Thanks in advance
... View more
03-08-2019
10:43 AM
|
0
|
5
|
1941
|
POST
|
When trying to use the overwrite() function, my code returns the following error: AttributeError: 'FeatureLayerCollection' object has no attribute 'managers' My code looks like the following: gis = GIS(username=username, password=password)
fs = gis.content.get('idoffeatureservice')
flc = FeatureLayerCollection.fromitem(fs)
flc.manager.overwrite("path to feature class inside an FGDB") Any ideas?
... View more
12-14-2017
01:34 PM
|
1
|
1
|
1964
|
POST
|
I encountered the exact same issue today. Both the option to export to FGDB via the AGOL GUI, as creating a replica via the REST endpoint fails. I have a featureservice with a few geometry layers, each with its own related standalone table. The standalone tables have attachments enabeled. I can export all of the layers, except for one standalone table (this one layer is also causing the 'create replica' to fail). I have been able to create replica's previously. The featureservice hoewever was taken offline of edits, and re-uploaded to AGOL. Retrieving the attachments is now problematic since the create replica option is the only way to get the attachments tables to download. I'd like to know if there is any way to check which attachments are corrupted, or if there is another workaround. I'm rather proficient with Python and JavaScript, so if anyone could share code/a workflow that would be amazing. I'd rather not go through the process described by scott. I find it rather odd that creating featureservices with attachments, and collecting photos in the field with collector is so easy, while retrieving these attachments after field-collection has to be such a hassle (a "Download Attachments" GUI option would be brilliant). Cheers
... View more
11-13-2017
07:37 AM
|
1
|
1
|
1418
|
POST
|
Robert, That worked like a charm! Thank you. I expanded a little bit on it and am now getting the related records as a response after selectedFeature changes: The code I used (might not be pretty, but it works): watchUtils.when(view.popup, "selectedFeature", function(evt){
console.log(view.popup.selectedFeature);
var url = view.popup.selectedFeature.layer.url;
var layerId = view.popup.selectedFeature.layer.layerId;
var fullURL = url + "/" + layerId;
var objectID = view.popup.selectedFeature.attributes.OBJECTID;
var queryTask = new QueryTask({
url: fullURL
});
relationQuery = new RelationshipQuery({
objectIds: [objectID],
outFields: ["*"],
relationshipId: 0
});
queryTask.executeRelationshipQuery(relationQuery).then(function(results){
console.log(results)
});
});
Now what I've got to do is append this to the content property of the popup. I'll keep this thread updated.
... View more
10-18-2017
01:32 PM
|
0
|
1
|
1124
|
POST
|
This still gives strange results. Sometimes, when clicking one feature, I get a burst of console logs (some of which are null, often one more than the previous burst). Also view.popup.attributes still doesnt work. Feels indeed like a timing thing, as all the logs happen before the popup draws.
... View more
10-16-2017
01:58 PM
|
0
|
3
|
1105
|
POST
|
Yes, see screenshot (erased some values in paint due to privacyreasons). view.popup.selectedFeature.attributes also gives an error
... View more
10-16-2017
12:28 PM
|
0
|
1
|
1105
|
POST
|
Vanilla might have been the wrong term there. The complexity of the sourcefile you linked is way beyond my understanding The selectedFeature property looks like the thing I need. I was able to implement it partly. I'm now getting an object returned as the selectedFeature after an on-click action. Two things: - To get the current selected feature I would need some kind of event listener. view.on("click", function(event) doesn't seem like the right one. - Trying to access the OBJECTID via view.popup.selectedFeature.attributes.OBJCTID gives me an error (also via data.getAttributes("OBJECTID")). How would one access this object?
... View more
10-16-2017
12:04 PM
|
0
|
3
|
1105
|
POST
|
Thanks for the response! Too bad this functionality isn't default (this seems to be the case in the vanilla options within for example webappbuilder). - - Some context: I have played around with speaking to the queryRelated REST endpoint directly via hitTest, getting all related records and appending them to a custom popup (with html markup). With this there were two issues: - Buggy peformance when hitting multiple features - Identity manager didnt seem to cover the authentication when getting the attachmentURL(of the related record) and displaying it -- End of context With the suggested idea of using QueryTask. In order to perform a QueryTask one would need an OBJECTID for the current selected feature (correct me if i'm wrong). Is there any other way to do this other than using hitTest?
... View more
10-16-2017
09:25 AM
|
0
|
5
|
1105
|
POST
|
I'm not sure if i'm overlooking things or this is not yet supported, but i'm curious if the default JavaScript API (v4) popup supports related records. I have the following situation: Hosted feature service on ArcGIS Online. In it three sublayers (trees, roads and vegetation). Each of the sublayers has a related table in which i store quality-inspection records (quality level, date of inspection and attachment-option). The relation is 1-m. Hosted feature service is added to a webmap which is also stored on AGO. In my custom front-end i created a mapView which loads the entire webmap at once (rather than adding all layer individually) Map draws perfectly and the popup works, but does not show the related records. Related records are however visible and editable in collector, explorer and via webappbuilder (see screenshot). Example in default JSAPI popup: Example in Webappbuilder: What i'm looking for is the option to add the functionality regarding the related records in the second screenshot to the situation in the first screenshot. My question is twofold: Is this supported by default and if yes, how do i turn it on? If this is not a default option, how would one go about and custom create this functionality?
... View more
10-15-2017
05:42 AM
|
2
|
16
|
3188
|
POST
|
I am running into a similar problem. In the WebApp Builder, when showing the related records to edit, the related records are sorted by a random field, instead of the one I configured in the webmap.
... View more
11-01-2016
04:28 AM
|
1
|
2
|
2329
|