Last active
September 30, 2018 13:44
-
-
Save HanOostdijk/bffc24403d73c262c2365f902bf93414 to your computer and use it in GitHub Desktop.
ODataV4 CBS $select question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start UPDATE 30SEP2018: | |
In a comment on https://www.linkedin.com/feed/update/urn:li:activity:6449917998194008064 | |
Dennis Ramondt (CBS Open Data) answers that the full $select functionality will be implemented only later | |
end UPDATE 30SEP2018 | |
Support for $select in beta version CBS OData4 | |
$select is not mentioned in the implementation document https://beta.opendata.cbs.nl/OData4/implement.html. | |
When using the construct on three different subtables of 900001NED it behaves differently as shown below. | |
Here I use R code but I get the same results when I use the urls in an internet browser. | |
Question: is this the intended behaviour? | |
In the remainder of the file: effect on TypegebruikCodes, MeasureCodes, Observations (and Observation without $select) | |
Works fine for TypegebruikCodes | |
tc1 =HOQCutil::get_table_cbs_odata4_GET( | |
"https://beta.opendata.cbs.nl/OData4/CBS-Maatwerk/900001NED/TypegebruikCodes?$select=Identifier,Title" | |
,response=T | |
) | |
HOQCutil::hard_split(httr::content(tc1,as='text'),80) | |
## [1] "{\"@odata.context\":\"https://beta.opendata.cbs.nl/OData4/CBS-Maatwerk/900001NED/$m" | |
## [2] "etadata#TypegebruikCodes(Identifier,Title)\",\"value\":[{\"Identifier\":\"A045558\",\"Ti" | |
## [3] "tle\":\"Energielevering; particuliere woning\"},{\"Identifier\":\"A045559\",\"Title\":\"En" | |
## [4] "ergielevering; zakelijke aansluiting\"}]}" | |
Gives an error for MeasureCodes | |
Apparently the result is an incomplete JSON expression. | |
The browser message is SyntaxError: JSON.parse: unexpected end of data at line 1 column 130 of the JSON data. | |
mc1 =HOQCutil::get_table_cbs_odata4_GET( | |
"https://beta.opendata.cbs.nl/OData4/CBS-Maatwerk/900001NED/MeasureCodes?$select=Identifier,Title" | |
,response=T | |
) | |
HOQCutil::hard_split(httr::content(mc1,as='text'),80) | |
## [1] "{\"@odata.context\":\"https://beta.opendata.cbs.nl/OData4/CBS-Maatwerk/900001NED/$m" | |
## [2] "etadata#MeasureCodes(Identifier,Title)\",\"value\":[" | |
Gives an exception for Observations | |
obs1 =HOQCutil::get_table_cbs_odata4_GET( | |
"https://beta.opendata.cbs.nl/OData4/CBS-Maatwerk/900001NED/Observations?$top=2&$select=Measure,Value" | |
,response=T | |
) | |
HOQCutil::hard_split(httr::content(obs1,as='text'),80) | |
## [1] "Error: Exception has been thrown by the target of an invocation." | |
Works fine for Observations without the $select | |
obs1 =HOQCutil::get_table_cbs_odata4_GET( | |
"https://beta.opendata.cbs.nl/OData4/CBS-Maatwerk/900001NED/Observations?$top=2" | |
,response=T | |
) | |
HOQCutil::hard_split(httr::content(obs1,as='text'),80) | |
## [1] "{\"@odata.context\":\"https://beta.opendata.cbs.nl/OData4/CBS-Maatwerk/900001NED/$m" | |
## [2] "etadata#Observations\",\"value\":[{\"Id\":1,\"Measure\":\"M00000001\",\"ValueAttribute\":\"N" | |
## [3] "one\",\"Value\":2060.0,\"PostCode6\":\"1011AC\",\"Typegebruik\":\"A045558\"},{\"Id\":2,\"Measu" | |
## [4] "re\":\"M00000001\",\"ValueAttribute\":\"None\",\"Value\":850.0,\"PostCode6\":\"1011AH\",\"Type" | |
## [5] "gebruik\":\"A045558\"}]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment