BIM 360 issue "Assigned To" - autodesk-forge

How can I change "Assigned To" from specific user to unspecified? I used {name: '-'} mainly for my UI which is obviously not enough to be used as input, perhaps {id: '', name: '-'} or {id: null, name: '-'}?

Update 2023-Jun
BIM360 issues API just released v2 API. Now it supports filtering assignedTo, assignedToType and displayId (in v1 called identifier). See here for the announcement: https://aps.autodesk.com/blog/bim-360-issues-version-2-api-released-1
Find the unassigned issues
curl --location --request GET 'https://developer.api.autodesk.com/issues/v2/containers/:issueContainerId/issues?filter[assignedTo]=null&filter[assignedToType]=null' \
--header 'Authorization: Bearer '
Find an issue by its displayId (in v1 called identifier)
curl --location --request GET 'https://developer.api.autodesk.com/issues/v2/containers/:issueContainerId/issues?filter[displayId]=14' \
--header 'Authorization: Bearer '
=========
We can specify null values to both assigned_to and assigned_to_type to remove the user from the issue and make it be unspecified.
curl --location --request PATCH 'https://developer.api.autodesk.com/issues/v1/containers/:issueContainerId/quality-issues/:issueId' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/vnd.api+json' \
--data-raw '{
"data": {
"type": "quality_issues",
"id": "{{issueId}}",
"attributes": {
"assigned_to": null,
"assigned_to_type": null
}
}
}'
API ref: https://forge.autodesk.com/en/docs/bim360/v1/reference/http/field-issues-:id-PATCH/

Related

Bitly: is is possible to create customs links via the API

I'd like to create a custom link via the API, that's to say instead of maclede12.co/3R8OeCm maclede12.co/magnifique. It is also referred as custom back-half.
I'm able to patch a link with the API via this request:
curl \
-H 'Authorization: Bearer token' \
-H 'Content-Type: application/json' \
-X PATCH \
-d '{
"id": "maclede12.co/3R8OeCm",
"custom_bitlinks": [
"maclede12.co/magnifique"
],
"tags": [
"bitly",
"api"
]
}' \
https://api-ssl.bitly.com/v4/bitlinks/maclede12.co/3R8OeCm
The tags are updated but I'm not able to get a custom link. The custom_bitlinks parameter comes from the doc but is it still even possible to do it?

FIWARE Orion, NGSIv2 subscription in attributes with structured values

I'm working with Orion Contex Broker and I need to receive notifications when a parameter in a structured attribute changes its value. An example:
Subscription:
curl -iX POST \
--url 'http://localhost:1026/v2/subscriptions' \
--header 'content-type: application/json' \
--data '{
"description":"Notify me of Store changes in street Address",
"subject":{
"entities":[
{
"idPattern":".*",
"type":"Store"
}
],
"condition":{
"attrs":[
"address.streetAddress"
]
}
},
"notification":{
"http":{
"url":"http://localhost:3000/subscription/store-change"
}
}
}'
Create entity:
curl -iX POST \
--url 'http://localhost:1026/v2/op/update' \
-H 'Content-Type: application/json' \
-d '{
"actionType":"append",
"entities":[
{
"type":"Store",
"id":"urn:ngsi-ld:Store:001",
"address":{
"type":"PostalAddress",
"value":{
"streetAddress":"Old",
"addressRegion":"Berlin"
}
},
"name":{
"type":"Text",
"value":"Bösebrücke Einkauf"
}
}
]
}'
Update the entity:
curl -iX PATCH \
--url 'http://localhost:1026/v2/entities/urn:ngsi-ld:Store:001/attrs' \
-H 'Content-Type: application/json' \
-d '{
"address":{
"type":"PostalAddress",
"value":{
"streetAddress":"Bornholmer"
}
}
}'
The expected result would be to receive a notification when the entity was created and update. Another possibility could be the "condition expressions". However one of kind: "q": "address.streetAddress!=${previousValue}" is not implemented yet.
Attributes within NGSI are usually numbers or strings - this typically leads to a very flat data model. In this case when the attribute value changes the subscription would be fired.
JSON objects (such as address above) are also supported, but the change occurs whenever the Object's value change and is not specifically bound to a sub attribute Hence
"attrs":[
"address.streetAddress"
]
Would need to be:
"attrs":[
"address"
]
However, the q parameter could be used to filter against a specific sub-attribute e.g. q=address.streetAddress!="Old" - and the listening interface could amend the subscription after it has fired.

Drive list files doesn't have nextPageToken when `fields` is present

When running this list files there is not a nextPageToken there is just files[].
curl \
'https://www.googleapis.com/drive/v3/files?fields=files(id%2C%20name)&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
result:
{
"files": [
{
"id": "1",
"name": "1"
},
...
{
"id": "2",
"name": "2"
}
]
}
Leaving the fields parameter empty, the nextPageToken is returned.
curl \
'https://www.googleapis.com/drive/v3/files?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
result:
{
"kind": "drive#fileList",
"nextPageToken": "~!!~AI9FV7TN...",
"incompleteSearch": false,
"files": [
{
"kind": "drive#file",
"id": "1",
"name": "1",
"mimeType": "application/vnd.google-apps.spreadsheet"
},
...
Is this a bug or is there some way to get the nextPageToken and limit the fields returned? The doc page for fields implies that it should work:
Note: The Drive API supports query parameters for data pagination (maxResults and nextPageToken). For APIs that support these parameters, use these parameters to reduce the results of each query to a manageable size. Otherwise, the performance gains possible with partial response might not be realized.
When fields=files(id,name) is used for the method of "Files: list", the file ID and filename are returned. In this case, the values of fields are files.id and files.name. nextPageToken is not included in fields. By this, the page token is not returned. When fields is not used, it seems that fields of nextPageToken,incompleteSearch,kind,files(id,name,kind,mimeType) is the default value. So I thought that this is not a bug, and it might be the current specification.
So when you want to retrieve nextPageToken when you use https://www.googleapis.com/drive/v3/files?fields=files(id%2C%20name), please include nextPageToken in fields as follows.
Modified curl command:
curl \
'https://www.googleapis.com/drive/v3/files?fields=nextPageToken%2Cfiles%28id%2Cname%29&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
In this case, fields is nextPageToken,files(id,name).
Result:
When above curl command is run, the following result is returned.
{
"nextPageToken": "###",
"files": [
{"id": "###", "name": "###"},
{"id": "###", "name": "###"},
,
,
,
]
}
Reference:
Files: list

Properly create CURL calls using loop in bash script

I need to call an API where I increment the user ID every time, I have the following in the bash script, but keep getting a Unexpected token ' in JSON at position 2 error. What am I doing wrong?
for ((i=1;i<=5;i++)); do
curl -X POST --header 'Content-Type: application/json' -d "{ 'id': 'person'$i, 'name':
'person', 'info': {} }" 'http://localhost:9999/add'
It is a quoting issue. It is standard for JSON to have double quotes, try this
for ((i=1;i<=5;i++)); do
echo "Adding person"$i
curl -X POST --header 'Content-Type: application/json' --header
'Accept: application/json' --user 'admin' -d '{ "id": "person'$i'", "name":
"person", "info": {} }" 'http://localhost:9999/add'
done
You can use jq, to ​​edit json by shellscript. See this link.

Pass boolean value in a curl request [duplicate]

This question already has answers here:
Passing a shell variable to a JSON request to curl?
(3 answers)
Closed 5 years ago.
My goal is to have an attribute isAdmin in my users schema that is a boolean value, defaulted to false, and can be sent a true value in a CURL request.
I started off with this in my schema:
isAdmin: {
type: Boolean,
default: false,
required: true
}
and have a working CURL request and the isAdmin returns false as expected.
API="http://localhost:4741"
URL_PATH="/sign-up"
EMAIL="a2#admin.com"
PASSWORD="test"
curl "${API}${URL_PATH}" \
--include \
--request POST \
--header "Content-Type: application/json" \
--data '{
"credentials": {
"email": "'"${EMAIL}"'",
"password": "'"${PASSWORD}"'",
"password_confirmation": "'"${PASSWORD}"'"
}
}'
I then tried to take the default value out:
isAdmin: {
type: Boolean,
required: true
}
..and try passing T or F in the CURL request and it's not working. The error says that isAdmin is required. Not sure what is wrong with my CURL request.
API="http://localhost:4741"
URL_PATH="/sign-up"
EMAIL="a2#admin.com"
PASSWORD="test"
ADMIN="True"
curl "${API}${URL_PATH}" \
--include \
--request POST \
--header "Content-Type: application/json" \
--data '{
"credentials": {
"email": "'"${EMAIL}"'",
"isAdmin": "'"${ADMIN}"'",
"password": "'"${PASSWORD}"'",
"password_confirmation": "'"${PASSWORD}"'"
}
}'
Any ideas as to what I am doing wrong? And/Or how I can have a default value of false and POST a new user with a true isAdmin attribute? Thank you in advance for any advice.
Clarification: Using Mongoose and ExpressAPI.
Since you are enclosing the value in double quotes, it seems to be treated as a string, rather than boolean. Try this:
ADMIN=true # may be it is safer to use all lowercase for true/false
curl "${API}${URL_PATH}" \
--include \
--request POST \
--header "Content-Type: application/json" \
--data '{
"credentials": {
"email": "'"${EMAIL}"'",
"isAdmin": '${ADMIN}',
"password": "'"${PASSWORD}"'",
"password_confirmation": "'"${PASSWORD}"'"
}
}'