GeoPlatform / client-api

Client-side interfaces for using the GeoPlatform API
Other
3 stars 0 forks source link

export item with format parameter #1

Open mhogeweg opened 6 years ago

mhogeweg commented 6 years ago

I was looking at the API and specifically the Export Item resource. I ended up with this request:

https://sit-ual.geoplatform.us/api/items/aede9f610a7aebbaaa208b25d29d0811/export?format=json

this returns an HTTP 406 error (Not Acceptable) wrapped in JSON. But json is listed as one of the options for the format parameter

{"statusCode":406,"message":"<!DOCTYPE html><html><head><title>Apache Tomcat/8.0.37 - Error report</title><style type=\"text/css\">H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76; border: none;}</style> </head>
<body><h1>HTTP Status 406 - </h1><div class=\"line\"></div><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request \"accept\" headers.</u></p><hr class=\"line\"><h3>Apache Tomcat/8.0.37</h3></body>
</html>","error":"Server Error","status":406,"stack":{}}

leaving off the format parameter does produce an ISO encoded XML document: https://sit-ual.geoplatform.us/api/items/aede9f610a7aebbaaa208b25d29d0811/export

pn-im commented 6 years ago

The error response is being returned due to a bug inside the data processing componentry within GeoPlatform which will be fixed in the upcoming release.

Exporting any GeoPlatform CBO object as JSON is the same as just requesting the object directly:

https://sit-ual.geoplatform.us/api/items/aede9f610a7aebbaaa208b25d29d0811/export?format=json is equivalent to... https://sit-ual.geoplatform.us/api/items/aede9f610a7aebbaaa208b25d29d0811

The api client library will be updated, though, to handle this case in order to return a more readable error indicating what went wrong and to contain clearer, more specific documentation.

mhogeweg commented 6 years ago

cool. I'm looking to see if I can hook up a 'multi-source' search widget to the Geoplatform API. you may see some more questions in the following weeks. one of the things I'll ask of the API is to return the item's metadata as XML. The above example returns an XML of sorts, but that doesn't appear to be a full ISO metadata document. Is there an item you know of that does have full metadata? or is it a seek and ye shall find situation?

pn-im commented 6 years ago

The current mechanism to get XML is the export feature using 'iso19139'.

For items created within the GeoPlatform, all data configured is exported to the appropriate ISO or ISO-GP extension property. For items imported from ISO (such as from Data.gov), there is currently some data loss possible during export if the item is modified after import (the original ISO values will not be exported in favor of the more current changed values).

In either case, we only export out what we can populate data with. Many metadata documents from places such as Data.gov have some incompleteness. That being said, exported XML from GP should be ISO-compliant.