Subscribe to this thread
Home - General / All posts - HTTP POSTs and PUTs
joebocop
454 post(s)
#31-Jan-21 03:34

After responding to the AirTable thread, I got to thinking.

If I have a table with a computed field, and that computed field contains a JSON representation of the record's other fields, is there a way I can POST (or PUT) that JSON data to an HTTP endpoint when one of the record's fields updates?

I can't figure out a way to get the Web Server:jsonserver data source component to a) accept a "Payload" property, or b) make a request type other than GET.

Instead of using the Data Source component, I tried (and failed) to make a WebRequest using a C# script. I'm not a .net dev, and I admit that I can't even get .net's system.net module accessible within M9. Blugh. I haven't been able to sort out how to make a request using JavaScript V8, which seems to lack that ability outside of using node.js.

Would be something of a holy grail to me to be able to "manage" data in M9, and have updates, inserts and deletes successfully pushed to a REST endpoint.

What should I try next? Thank you.

Dimitri


6,511 post(s)
online
#01-Feb-21 07:39

Would be something of a holy grail to me to be able to "manage" data in M9, and have updates, inserts and deletes successfully pushed to a REST endpoint.

Very often, people who operate REST servers make sure you cannot do that. They don't want outsiders writing to their database, and they often don't even want to give access to the database so you can scrape the data from it. Most internet map servers are set up to be display-only by default.

The classic architecture for web servers that display maps is a two or three part ensemble:

1) All the actual spatial data is in a database like SQL Server, Oracle, PostgreSQL, etc.

2) An internet map server of some kind displays content from that database on demand, usually rasterising it for display purposes (rendering it) as .png or .jpg or whatever tiles that are sent to browsers. Turning vector data into raster data that is no longer tied to a GIS coordinate system is an effective way of showing a picture of the data without letting people get at the actual vector data for their own GIS use.

3) (optional) People will use a GIS package like Manifold as a client to connect to the database, to load, update, delete, and otherwise edit data. That client connects to the database either using native database drivers or ODBC or some other database connection technology. It doesn't normally connect back through the internet map server.

In your case, the way to use 9 to manage data within databases (which some internet map server publishes to browsers) is to connect directly to the database of interest. See the Databases topic.

joebocop
454 post(s)
#01-Feb-21 18:28

Thank you Dimitri.

Can an HTTP request be executed from within a Script in Release 9?

If so, then couldn't SQL9 functions be wrapped around those Script entry points to do create/update/delete work on URLs?

In cases where native access to a database over the public web is not possible, but where data access is provided via REST, Manifold is already a great tool. The built-in Data Source types (csvserver, jsonserver, geojsonserver and arcgisrest) are excellent for pulling data into a project. Thereafter, the heavy lifting can take place.

It's not a stretch for me to imagine Manifold being able to exploit the additionally advertised abilities of such APIs to also create new records, edit records, and delete records. Using scripts, I'm almost certain this capability is within reach already, without having to make a Suggestion or other extension to Manifold itself.

The API I use daily is Fulcrum's, since we do our field data collection using that platform. Fulcrum exposes Create, Read, Update and Delete functionality over authorized HTTP, so we use python (with requests) and postgresql/postgis to do our analysis and transformation work, and then to push any needed changes back to the Fulcrum platform. Doing it all within Manifold would be better.

Manifold User Community Use Agreement Copyright (C) 2007-2019 Manifold Software Limited. All rights reserved.