How to Update an AGOL Feature Service....for beginners

804
3
Jump to solution
02-27-2020 10:27 AM
BrianBulla1
Occasional Contributor

Hi,

So I've created a Feature Service in AGOL, and I'm just trying out how to update it through the REST Services Directory.  I can't seem to get the syntax figured out.  

From what I've read I need the GlobalID of the feature I want to update, as well as whatever attributes.  When I try the following, I get errors, but I'm not really sure what I need to fix.

Also, is it possible to update without using the GlobalID?  We have another unique attribute on each feature (FACILITYID) which I would prefer to use.

Thanks,

So doing this....

Produces this error....

0 Kudos
1 Solution

Accepted Solutions
RandyBurton
MVP Alum

Your json is missing a comma after "LOW".   You can check your json using a service like jsonlint.com.

[{
	"attributes": {
		"ADMINISTRA": "LOW"
		"GlobalID": "{a8917ecd-d21e-46ce-b34a-46b0be3e5b4c}"
	}
}]

Result from jsonlint.com:

Error: Parse error on line 3:
...DMINISTRA": "LOW"		"GlobalID": "{a8917e


Correction:

[{
	"attributes": {
		"ADMINISTRA": "LOW",
		"GlobalID": "{a8917ecd-d21e-46ce-b34a-46b0be3e5b4c}"
	}
}]

Result from jsonlint.com:

Valid JSON

View solution in original post

3 Replies
RandyBurton
MVP Alum

Your json is missing a comma after "LOW".   You can check your json using a service like jsonlint.com.

[{
	"attributes": {
		"ADMINISTRA": "LOW"
		"GlobalID": "{a8917ecd-d21e-46ce-b34a-46b0be3e5b4c}"
	}
}]

Result from jsonlint.com:

Error: Parse error on line 3:
...DMINISTRA": "LOW"		"GlobalID": "{a8917e


Correction:

[{
	"attributes": {
		"ADMINISTRA": "LOW",
		"GlobalID": "{a8917ecd-d21e-46ce-b34a-46b0be3e5b4c}"
	}
}]

Result from jsonlint.com:

Valid JSON
RandyBurton
MVP Alum

Regarding your question about using the GlobalID, the documentation says:

The attributes property of the feature should include the object ID (and the global ID, if available) of the feature along with the other attributes.

I have used just the OBJECTID field without the global ID (it is a bit to complex to type easily) to update features on AGOL.

If you want to use the FACILITYID, one way would be to use it to query the feature to obtain the OBJECTID and/or GlobalID.  Then use the OBJECTID to make the update.

BrianBulla1
Occasional Contributor

Hi Randy,

Thanks for the help.  I ended up getting things working, but only after using the FID (as well as adding the comma).  For some reason it would not work with just the OBJECTID.

[{
"attributes": {
"ADMINISTRA": "LOW",
"FID": "227"
}
}]

0 Kudos