Fiware Scorpio appending new attribute to existing entity - fiware

I tried to append a new entity to an existing entity.
Same as in the official example on:
https://scorpio.readthedocs.io/en/latest/API_walkthrough.html#updating-an-entity-appending-to-an-entity
Try to append attribute humidity:
curl localhost:9090/ngsi-ld/v1/entities/house2%3Asmartrooms%3Aroom1/attrs -s -S -X PATCH -H 'Content-Type: application/json' -H 'Link: https://pastebin.com/raw/Mgxv2ykn' -d #- <<EOF
{
"humidity": {
"value": 34,
"unitCode": "PER",
"type": "Property",
"providedBy": {
"type": "Relationship",
"object": "smartbuilding:house2:sensor2222"
}
}
}
But I receive the error:
{
https://uri.etsi.org/ngsi-ld/default-context/notUpdated : [ {
https://uri.etsi.org/ngsi-ld/attributeName : {
"#id" : https://uri.etsi.org/ngsi-ld/default-context/humidity
},
https://uri.etsi.org/ngsi-ld/reason : "attribute not found in original entity"
} ]
}
Can anybody tell me, if they encounter the same problem?
Or how to fix this?
Thank you in advance!

Hi if you want to append new attribute in existing entity so you should use POST request instead of PATCH.
Sorry for inconvenience, we will update in document as well.
Thanks,
Amit Raghav.

Related

Potential Error in Forge Post Job Docs with destination

Looking at the documentation for the Forge Post Job. The examples show that region is a sub object of destination. However the docs seem to show that they are on the same level.
Doc was uploaded as image.
Curl Request Example:
curl -X 'POST' \
[![enter image description here][2]][2]-H 'Content-Type: application/json; charset=utf-8' \
-H 'Authorization: Bearer PtnrvrtSRpWwUi3407QhgvqdUVKL'
-v 'https://developer.api.autodesk.com/modelderivative/v2/designdata/job' \
-d
'{
"input": {
"urn": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bW9kZWxkZXJpdmF0aXZlL0E1LnppcA",
"compressedUrn": true,
"rootFilename": "A5.iam"
},
"output": {
"destination": {
"region": "us"
},
"formats": [
{
"type": "svf",
"views": [
"2d",
"3d"
]
}
]
}
}'
Thanks for reporting this.
I've let our Dev Portal team know to take a look and will get back to you once they fix this up. Thanks!

Bash script to insert variables into a json payload (slack webhook) question [duplicate]

This question already has answers here:
Curl command issue in bash script because of string variable containing quotes [duplicate]
(2 answers)
Closed 3 years ago.
I am trying to insert a variable into my json payload (working in shell script) but I am unsure of how to escape the characters properly
I've tried many different escape methods but I'm a total noob at it and I either return the literal string or it doesn't run
SLACK_ALERT_WEBHOOK=desiredurl
curl -X POST -H 'Content-type: application/json' --data '{"text": "*Daily Webhook Verification*", "attachments": [
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Slack post failed for webhook, please investigate: $SLACK_ALERT_WEBHOOK"
}
}
]
}
]}' "$SLACK_ALERT_WEBHOOK"
I just want to insert the value of SLACK_ALERT_WEBHOOK into this portion of the code "text": "Slack post failed for webhook, please investigate: $SLACK_ALERT_WEBHOOK but it either doesn't run or returns the literal string. I have the bottom "$SLACK_ALERT_WEBHOOK" working successfully at the bottom to send to my desired slack channel so I'm not worried about that.
I've got it working thanks to tripleee:
curl -X POST -H 'Content-type: application/json' --data "{\"text\": \"*Verification*\", \"attachments\": [{\"blocks\": [{\"type\": \"section\",\"text\": {\"type\": \"mrkdwn\",\"text\": \"$SLACK_ALERT_WEBHOOK\"}}]}]}" $SLACK_ALERT_WEBHOOK
Try this:
SLACK_ALERT_WEBHOOK=desiredurl
$(curl -X POST -H 'Content-type: application/json' --data '{"text": "*Daily Webhook Verification*", "attachments": [
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Slack post failed for webhook, please investigate: `echo $SLACK_ALERT_WEBHOOK`"
}
}
]
}
]}' "`echo $SLACK_ALERT_WEBHOOK`")
Using the echo <<variable>> it should just run that as a command. I tested it on my own server, but might work differently on yours. Hope it helps.

How to import a big JSON-file to a Docker-swarm cluster with ELK stack?

Basically I want to import JSON-data into (Logstash->ElasticSearch->) Kibana, but I'm completely new and stuck at the different methods, which I do not fully understand and get errors or no output.
What I've got is a file test.json containing Wikipedia-data in this format:
{
"results": [
{
"curr": "Ohio_\"Heartbeat_Bill\"",
"n": 43,
"prev": "other-external",
"type": "external"
},
{
"curr": "Ohio_\"Heartbeat_Bill\"",
"n": 1569,
"prev": "other-search",
"type": "external"
},
{
"curr": "Ohio_\"Heartbeat_Bill\"",
"n": 11,
"prev": "other-internal",
"type": "external"
},
...
And so on. The file is 1.3Mb big, because I've deleted some of the largest examples.
I tried the curl command:
cat test.json | jq -c '.[] | {"index": {}}, .' | curl -XPOST localhost:9200/_bulk --data-binary #-
and
curl -s -XPOST localhost:9200/_bulk --data-binary #test.json
and
write "{ "index" : { } }" at the beginning of the document
I also tried:
curl -XPUT http://localhost:9200/wiki -d '
{
"mappings" : {
"_default_" : {
"properties" : {
"curr" : {"type": "string"},
"n" : {"type": "integer"},
"prev" : {"type": "string"},
"type" : {"type": "string"}
}
}
}
}
';
But I always get this error:
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}
Or when I use:
curl localhost:9200/wiki -H "Content-type:application/json" -X POST -d #test.json
I get:
{"error":"Incorrect HTTP method for uri [/wiki] and method [POST], allowed: [GET, HEAD, DELETE, PUT]","status":405}
And when I replace "wiki" with "_bulk", like all the examples seem to have in common, then I get:
{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication token for REST request [/_bulk]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"missing authentication token for REST request [/_bulk]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}},"status":401
I also have copy-pasted-and-adjusted-as-far-as-I-understood the conf-file in Kibana-Logstash-Pipeline like this:
input
{
file
{
codec => multiline
{
pattern=> '^\{'
negate=> true
what=> previous
}
path => ["/home/user/docker-elastic/examples/pretty.json"]
start_position => "beginning"
sincedb_path => "/dev/null"
exclude => "*.gz"
}
}
filter
{
mutate
{
replace => [ "message", "%{message}}" ]
gsub => [ 'message','\n','']
}
if [message] =~ /^{.*}$/
{
json { source => message }
}
}
output
{
elasticsearch {
protocol => "http"
codec => json
host => "localhost"
index => "wiki_json"
embedded => true
}
stdout { codec => rubydebug }
}
But when I click "create and deploy" nothing happens.
So I have tried some examples, but like I said - I don't fully understand them and have therefore trouble getting my data to Kibana. I've written Logstash and ElasticSearch, because I would love to pass the data by using those, too.
Can somebody please explain to me, how I can pass this data directly, without manually altering the file? Many answers said that the data cannot be passed in the structure I have but must be "one line, one input"-only. But I cannot alter the whole file with nearly 40000 data by hand and I would like not have to write a python-script for it..
Maybe there is a tool or something? Or maybe I'm just too stupid to understand the syntax and am doing something wrong?
Any help is appreciated!
Thank you in advance!
Like #Ian Kemp answered in the comment section, the Problem was that I used POST and not PUT. After that I got an error saying that authentification failed, so I googled for it and got the final answer:
curl elastic:changeme#localhost:9200/wiki -H "Content-type: application/json" -X PUT -d #test.json
with the index line in the file.
This is the structure of how I finally got the data to be in Elasticsearch :)
THANK YOU very much Ian Kemp!

Deleting a file from bucket. Autodesk-forge

There are problem with deleting a file from wip.dm.prod bucket ("errorCode": "AUTH-012"). But I can download current file by using -x GET instead of -x DELETE.
I use this tutorial -> https://developer.autodesk.com/en/docs/data/v2/reference/http/buckets-:bucketKey-objects-:objectName-DELETE/ . Attach an example below.
Request
curl
-v https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/de34f4c9-457c-4653-a9e4-8bbad12bf5ec.rvt
-X DELETE
-H "Authorization:Bearer G3fqI9NFKqJVN5MQy3yI0tGXXXXX"
Response
{
"developerMessage": "ACM check failed, user or calling service does not have access to perform this operation",
"userMessage": "",
"errorCode": "AUTH-012",
"more info": "http://developer.api.autodesk.com/documentation/v1/errors/AUTH-012"
}
Could you please check me and explain me what could be wrong?
For file deleting we can use deleting of file version.
curl
-v https://developer.api.autodesk.com/data/v1/projects/{project_Id}/versions
-x POST
-H "Authorization:Bearer G3fqI9NFKqJVN5MQy3yI0tGXXXXX"
-H "Content-Type:application/vnd.api+json"
-d '{
"jsonapi": {
"version": "1.0"
},
"data": {
"type": "versions",
"attributes": {
"extension": {
"type": "versions:autodesk.core:Deleted",
"version": "1.0",
}
},
"relationships": {
"item": {
"data": {
"type": "items",
"id": "urn:adsk.___your_file_id__________"
}
}
}
}
}'
Where:
{project_Id} - is your project id;
"urn:adsk.___your_file_id__________" - is your file id.

cURL Response JSON RestAPI

I need to delete some wrong data, inserted in a lot of processes, and I need to figure if this is possible with cURL and rest API, with a script in sh, batch or something like this:
curl -u admin:admin -i -H "Accept: application/json" -X GET "http://json_bpm.com/wle/v1/service/6112449?action=getData&fields=context"
First I just need the result map.
Output:
{"status":"200","data":{"result":"{\"context\":{\"name\":\"xxx\" (...)
"resultMap":{"context":{"name\":"xxx\" (...) }}}
Because I need to remove the userDelete array (see below) for thousands of processes, and set this again using curl. If you know how to remove arrays from JSON too, you're the man. :)
{
"context": {
"name": "Change Process",
"startUser": {
"user": "0001"
},
"endUser": {
"user": "0001"
},
"userDelete": {
"user": "0002"
},
"origin": "GUI",
"userAction": "Change Process"
}
}