Does Orion support GeoJSON format? - fiware

I am trying to create an entity using GeoJSON for it location:
{
"id": "1234",
"name": "test",
"type": "TestDevice",
"location": {
"value": {
"type": "Point",
"coordinates": [2.186447514, 41.3763726, 143.148]
},
"type": "geo:json"
}
}
but I am getting this error:
{
"error": "BadRequest",
"description": "attribute must be a JSON object, unless keyValues option is used"
}
Does the GeoJSON supported by Orion?
I am using orion on docker:
"version": "1.8.0-next"
Thanks and best regards

It is not a problem of geo:json support
It is the attribute name that causes this issue. It should be like the following:
{
"id": "1234",
"name": {
"value": "test",
"type": "String"
},
"type": "TestDevice",
"location": {
"value": {
"type": "Point",
"coordinates": [2.186447514, 41.3763726, 143.148]
},
"type": "geo:json"
}
}

Related

How to parse a dynamic Json - Power Automate

Im getting a http response from Azure LogAnalytics, the response is a Json like this
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "TimeGenerated",
"type": "datetime"
},
{
"name": "DestinationIP",
"type": "string"
},
{
"name": "DestinationUserName",
"type": "string"
},
{
"name": "country_name",
"type": "string"
},
{
"name": "country_iso_code",
"type": "string"
},
{
"name": "AccountCustomEntity",
"type": "string"
}
],
"rows": [
[
"2021-05-17T14:07:01.878Z",
"158.000.000.33",
"luis",
"United States",
"US",
"luis"
]
]
}
]
}
I will never get the same colums or sometimes i will get more rows with data like this
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "Account",
"type": "string"
},
{
"name": "Computer",
"type": "string"
},
{
"name": "IpAddress",
"type": "string"
},
{
"name": "AccountType",
"type": "string"
},
{
"name": "Activity",
"type": "string"
},
{
"name": "LogonTypeName",
"type": "string"
},
{
"name": "ProcessName",
"type": "string"
},
{
"name": "StartTimeUtc",
"type": "datetime"
},
{
"name": "EndTimeUtc",
"type": "datetime"
},
{
"name": "ConnectinCount",
"type": "long"
},
{
"name": "timestamp",
"type": "datetime"
},
{
"name": "AccountCustomEntity",
"type": "string"
},
{
"name": "HostCustomEntity",
"type": "string"
},
{
"name": "IPCustomEntity",
"type": "string"
}
],
"rows": [
[
"abc\\abc",
"EQ-DC02.abc.LOCAL",
"0.0.0.0",
"User",
"4624 - An account was successfully logged on.",
"10 - RemoteInteractive",
"C:\\Windows\\System32\\svchost.exe",
"2021-05-17T15:02:25.457Z",
"2021-05-17T15:02:25.457Z",
2,
"2021-05-17T15:02:25.457Z",
"abc\\abc",
"EQ-DC02.abc.LOCAL",
"0.0.0.0"
],
[
"abc\\eona",
"EQPD-SW01.abc.LOCAL",
"0.0.0.0",
"User",
"4624 - An account was successfully logged on.",
"10 - RemoteInteractive",
"C:\\Windows\\System32\\svchost.exe",
"2021-05-17T15:21:45.993Z",
"2021-05-17T15:21:45.993Z",
1,
"2021-05-17T15:21:45.993Z",
"abc\\abc",
"EQPD-SW01.abc.LOCAL",
"0.0.0.0"
]
]
}
]
}
Im using Power Automate to parse this kind of Json to a Object or to make a response
the question is, how can i parse this "Columns" and "Rows" to a object?
Similar discussion happened in community forum and the solution identified was:
parse JSON and transform it to XML and then search keys with XPATH in Flow

Json parse is giving null values

I have a logic app which gets Address info using Bind Rest Api. I received a nested json object. When I tried to parse it, I'm getting null values in dynamix syntax box.
Below is the json object that I get, however when I use these as properties after parsing, they are marked as null:
{
"address": {
"addressLine": "1-11-252, Begumpet Road",
"adminDistrict": "TS",
"adminDistrict2": "Hyderabad",
"countryRegion": "India",
"formattedAddress": "1-11-252, Begumpet Road, Hyderabad, TS 500016",
"intersection": {
"baseStreet": "Begumpet Road",
"secondaryStreet1": "Chikoti Garden No-4 Road",
"intersectionType": "Near",
"displayName": "Begumpet Road and Chikoti Garden No-4 Road"
},
"locality": "Hyderabad",
"neighborhood": "Begumpet",
"postalCode": "500016",
"countryRegionIso2": "IN"
}
}
Based on your information, here's what I did:
Created a Logic App in the Azure portal
Selected the "When a HTTP request is received" trigger
Clicked "Use sample payload to generate schema" link and pasted your example data (SEE BELOW!)
Added a "Response" action
Defined the response's body to be:
{
"address": baseStreet
}
Where baseStreet is a reference to the baseStreet dynamic content.
The result:
IMPORTANT!
Please be advised that the Request Body JSON Schema is different than the payload:
{
"type": "object",
"properties": {
"address": {
"type": "object",
"properties": {
"addressLine": {
"type": "string"
},
"adminDistrict": {
"type": "string"
},
"adminDistrict2": {
"type": "string"
},
"countryRegion": {
"type": "string"
},
"formattedAddress": {
"type": "string"
},
"intersection": {
"type": "object",
"properties": {
"baseStreet": {
"type": "string"
},
"secondaryStreet1": {
"type": "string"
},
"intersectionType": {
"type": "string"
},
"displayName": {
"type": "string"
}
}
},
"locality": {
"type": "string"
},
"neighborhood": {
"type": "string"
},
"postalCode": {
"type": "string"
},
"countryRegionIso2": {
"type": "string"
}
}
}
}
}
When running with the Parse JSON step:

Multiple values for a property on resource in Azure ARM Template

According to https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple#property-iteration it should be possible to create multiple values on a resource using copy but I can't make it work. Here is my code...
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appServiceName": {
"type": "string",
"metadata": {
"description": "Name of app service to apply SSL to."
}
},
"certificateName": {
"type": "string",
"metadata": {
"description": "User friendly certificate resource name"
}
},
"appServicePlan": {
"type": "string",
"metadata": {
"description": "App Service Plan Name"
}
},
"keyVaultId": {
"type": "string",
"metadata": {
"description": "Existing Key Vault resource Id with an access policy to allow Microsoft.Web RP to read Key Vault secrets (Checkout README.md for more information)"
}
},
"hostname": {
"type": "array",
"metadata": {
"description": "Custom hostname for creating SSL binding. This hostname should already be assigned to the Web App"
}
}
},
"resources": [
{
"apiVersion": "2017-03-30",
"type": "Microsoft.Web/sites",
"name": "[parameters('appServiceName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/certificates', parameters('certificateName'))]"
],
"properties": {
"copy": [
{
"name": "hostnames",
"count": "[length(parameters('hostname'))]",
"input": {
"name": "[copyIndex('hostnames')]",
"properties": {
"hostNameSslStates": [
{
"name": "[[copyIndex(hostname)]]",
"sslState": "SniEnabled",
"thumbprint": "[reference(resourceId('Microsoft.Web/certificates', parameters('certificateName'))).Thumbprint]",
"toUpdate": true
}
]
}
}
}
]
}
},
{
"type": "Microsoft.Web/certificates",
"name": "[parameters('certificateName')]",
"apiVersion": "2016-03-01",
"location": "[resourceGroup().location]",
"properties": {
"keyVaultId": "[parameters('keyVaultId')]",
"keyVaultSecretName": "[parameters('certificateName')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms',parameters('appServicePlan'))]"
}
}
]
}
And it returns Error: Code=InvalidTemplate; Message=Deployment template l
anguage expression evaluation failed: 'Unable to parse language expression 'copyIndex(hostname)]': expecte
d token 'LeftParenthesis' and actual 'RightParenthesis'.'. Please see https://aka.ms/arm-template-expressi
ons for usage details.
Any ideas what am I doing wrong?
Thanks in advance!
the error gives is away:
change "[[copyIndex(hostname)]]", to "[copyIndex('hostname')]"
you even have it right in other places, why not here?
and you probably want to do this:
"[parameters('hostname')[copyIndex('hostname')]]"

Error adding docs to CouchDB

My local PouchDB docs won't replicate to my remote CouchDB.
The sync is happening, because the browser downloaded my design schema, so it's not a permissions issue. I think that my design schema doesn't match my documents, but I struggled to find the correct way to write the schema.
Schema
{
"_id": "_design/schema",
"_rev": "4-3d9a49ebffbbd6b7b146240879baa7e4",
"validate_doc_update": "function(newDoc, oldDoc, userCtx, secObj){ if(userCtx.roles[0] !== 'admin'){throw({forbidden: 'operation forbidden'})} }",
"views": {
"by_module": {
"map": "function(doc){ if(doc.type == 'note'){emit(doc.note);} }"
}
},
"schema": {
"title": "Contact details",
"description": "A document containing a person's contact details.",
"type": "object",
"required": [
"name",
"level"
],
"properties": {
"_id": {
"type": "string"
},
"_rev": {
"type": "string"
},
"application_access": {
"type": "string"
},
"home": {
"type": "string"
},
"home_email": {
"type": "string"
},
"jobtitle": {
"type": "string"
},
"level": {
"type": "string"
},
"mobile1": {
"type": "string"
},
"mobile2": {
"type": "string"
},
"modified": {
"type": "number"
},
"name": {
"type": "string"
},
"work": {
"type": "string"
},
"work_email": {
"type": "string"
},
"_doc_id_rev": {
"type": "string"
}
}
}
}
Doc
{
"_id": "fcb52b3072e2038647b328c0a700147f",
"_rev": "1518449239461",
"application_access": "User",
"home": "",
"home_email": "",
"jobtitle": "Exemplar",
"level": "Bronze",
"mobile1": "0987654321",
"mobile2": "",
"modified": 1518449239461,
"name": "Zachary Zumbeispiel",
"work": "",
"work_email": "",
"_doc_id_rev": "1518449239460::1-ffd3c056614845ada4a68de4793710ac"
}
So the question is, does my doc conform to my schema? Or is my schema wrong?
The "schema" was on the CouchDB instance, and the doc was in PouchDB.
They are replicating now, because I removed the "document schema" and so it can sync & replicate.
So the problem was that I had read somewhere that I needed to add a schema to CouchDB, so I created what I thought was a schema, and evidently the structure of the docs to be synced has to be the same, so the sync did not work because the structure of the docs did not match.
Hence #Flimzy 's explanation that the whole notion of a schema was bobbins meant that I removed the "schema", and voila, the PouchDB and CouchDB can now sync - and problem solved.

Fiware Context Broker with entities geolocated

I have a problem in retrieving entities using georeferenced queries.
Use the v2 syntax.
This is my query:
GET /v2/entities?georel=near;maxDistance:1000&geometry=point&coords=13.52,43.61
and this is my entity:
{
"id": "p1",
"type": "pm",
"address": {
"type": "Text",
"value": "Via Roma "
},
"allowedVehicleType": {
"type": "Text",
"value": "car"
},
"category": {
"type": "Text",
"value": "onstreet"
},
"location": {
"type": "geo:json",
"value": {
"type": "Point",
"coordinates": [ 13.5094, 43.6246 ]
}
},
"name": {
"type": "Text",
"value": "p1"
},
"totalSpotNumber": {
"type": "Number",
"value": 32
}
}
What is wrong?
I followed the official documentation but I can not get any results as well.
I also tried to reverse the coordinates, but the result does not change.
Any suggestion is welcome.
Note that longitude comes before latitude in GeoJSON coordinates, while the coords parameters does in the opposite way.
Thus, assuming that your entity is located in Ancona city, I think that using "coordinates": [ 43.6246, 13.5094 ] will solve the problem.