Box Api - How to Get user details who commented a file - node.js

I have a scenario in Box of commenting a file using Box Api. I have used Box api to add a comment. When displaying all the comments, it shows commented person name same for all comments.
How should I add a comment to differentiate who has commented it using Box API
Sample comment List:
{
"type": "comment",
"id": "1111",
"is_reply_comment": false,
"message": "Sample Comment 1",
"created_by": {
"type": "user",
"id": "111",
"name": "AAA",
"login": "aaa#aaa.com"
},
"created_at": "2016-08-11T00:01:56-07:00",
"item": {
"id": "78110824178",
"type": "file"
},
"modified_at": "2016-08-11T00:01:56-07:00"
}
{
"type": "comment",
"id": "2222",
"is_reply_comment": false,
"message": "Sample Comment 2",
"created_by": {
"type": "user",
"id": "111",
"name": "AAA",
"login": "aaa#aaa.com"
},
"created_at": "2016-08-11T00:01:56-07:00",
"item": {
"id": "78110824178",
"type": "file"
},
"modified_at": "2016-08-11T00:01:56-07:00"
}
Please help to add comments for different users

To comment as a specific user, you can use the As-User header. Here is an example:
curl https://api.box.com/2.0/comments \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "As-User: USER_ID" \
-d '{"item": {"type": "file", "id": "FILE_ID"}, "message": "YOUR_MESSAGE"}' \
-X POST

Related

Nodejs Customized JSON from lucid response

I have the following result set from the database, The result is an array of objects but I want it to look alike a nested objects as shown in the example.
[
{
"id": 4,
"entity": "dashboard",
"key": "message",
"value": "How to watch Netflix with XXX on Android?",
"locale": "en",
"created_at": "2022-10-25T14:41:38.000+05:00",
"updated_at": "2022-10-25T14:41:38.000+05:00"
},
{
"id": 9,
"entity": "in_survey",
"key": "content",
"value": "",
"locale": "en",
"created_at": "2022-10-25T14:41:38.000+05:00",
"updated_at": "2022-10-25T14:41:38.000+05:00"
}
]
Need a response like this from the above JSON
{
"dashboard": {
"message": "How to watch XYZ on Android?",
},
"in_survey": {
"content": ""
}
}

Question on Visualization of FIWARE STH data with Grafana

I have a question based on FIWARE timescale database design when using STH and grafana for visualization.
**Background**:
I created a test project based on FIWARE using Docker-Compose. The project currently includes:
Orion-LD + Mongo-DB
STH based on Mintaka and Timescale-DB
OPC UA Dummy Car Server and OPC UA IoT-Agent
Grafana
The solutions seems to work quite well: OPC UA dummy car server sends data via OPC UA Iot-Agent and I can also send commands back to OPC dummy car server. I am also able to query historic context for the car entity using orion-ld:
Request
curl --location --request GET 'http://localhost:8080/temporal/entities/?type=Device&pageSize=2&lastN=3&timeproperty=modifiedAt&options=count&timerel=before&timeAt=2022-07-15T15:28:00Z' \
--header 'NGSILD-Tenant: opcua_car' \
--header 'Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'\''' \
--header 'NGSILD-Path: /demo'
Response:
[
{
"id": "urn:ngsi-ld:Device:age01_Car",
"type": "Device",
"Acceleration": [
{
"type": "Property",
"value": 0.0,
"modifiedAt": "2022-07-15T13:40:02.960Z",
"instanceId": "urn:ngsi-ld:attribute:instance:a10c6606-0443-11ed-9e31-0242ac120103"
},
{
"type": "Property",
"value": 3.0,
"modifiedAt": "2022-07-15T13:40:01.978Z",
"instanceId": "urn:ngsi-ld:attribute:instance:a0775408-0443-11ed-9cfd-0242ac120103"
},
{
"type": "Property",
"value": 0.0,
"modifiedAt": "2022-07-15T13:25:54.342Z",
"instanceId": "urn:ngsi-ld:attribute:instance:a73b926a-0441-11ed-bca6-0242ac120103"
}
],
"Stop_status": {
"type": "Property",
"value": {
"type": "commandStatus",
"#value": "UNKNOWN"
},
"modifiedAt": "2022-07-15T13:21:24.893Z",
"instanceId": "urn:ngsi-ld:attribute:instance:06a2ed12-0441-11ed-b967-0242ac120103"
},
"Engine_Oxigen": [
{
"type": "Property",
"value": 80.0,
"modifiedAt": "2022-07-15T13:24:41.752Z",
"instanceId": "urn:ngsi-ld:attribute:instance:7bf736f4-0441-11ed-8bcd-0242ac120103"
},
{
"type": "Property",
"value": 78.5,
"modifiedAt": "2022-07-15T13:24:40.734Z",
"instanceId": "urn:ngsi-ld:attribute:instance:7b5c32e4-0441-11ed-ac6e-0242ac120103"
},
{
"type": "Property",
"value": 77.0,
"modifiedAt": "2022-07-15T13:24:39.726Z",
"instanceId": "urn:ngsi-ld:attribute:instance:7ac21740-0441-11ed-b111-0242ac120103"
}
],
"Stop_info": {
"type": "Property",
"value": {
"type": "commandResult",
"#value": " "
},
"modifiedAt": "2022-07-15T13:21:24.893Z",
"instanceId": "urn:ngsi-ld:attribute:instance:06a2ed8a-0441-11ed-b967-0242ac120103"
},
"Accelerate_info": {
"type": "Property",
"value": {
"type": "commandResult",
"#value": " "
},
"modifiedAt": "2022-07-15T13:21:24.893Z",
"instanceId": "urn:ngsi-ld:attribute:instance:06a2ee66-0441-11ed-b967-0242ac120103"
},
"Error_status": {
"type": "Property",
"value": {
"type": "commandStatus",
"#value": "UNKNOWN"
},
"modifiedAt": "2022-07-15T13:21:24.893Z",
"instanceId": "urn:ngsi-ld:attribute:instance:06a2ec0e-0441-11ed-b967-0242ac120103"
},
"Accelerate_status": {
"type": "Property",
"value": {
"type": "commandStatus",
"#value": "UNKNOWN"
},
"modifiedAt": "2022-07-15T13:21:24.893Z",
"instanceId": "urn:ngsi-ld:attribute:instance:06a2edf8-0441-11ed-b967-0242ac120103"
},
"EngineStopped": [
{
"type": "Property",
"value": true,
"modifiedAt": "2022-07-15T13:23:50.922Z",
"instanceId": "urn:ngsi-ld:attribute:instance:5dab3b8c-0441-11ed-9f1d-0242ac120103"
},
{
"type": "Property",
"value": true,
"modifiedAt": "2022-07-15T13:21:25.497Z",
"instanceId": "urn:ngsi-ld:attribute:instance:06fd291c-0441-11ed-9ed9-0242ac120103"
}
],
"Engine_Temperature": [
{
"type": "Property",
"value": 80.0,
"modifiedAt": "2022-07-15T13:24:21.691Z",
"instanceId": "urn:ngsi-ld:attribute:instance:70023236-0441-11ed-8db7-0242ac120103"
},
{
"type": "Property",
"value": 78.0,
"modifiedAt": "2022-07-15T13:24:20.700Z",
"instanceId": "urn:ngsi-ld:attribute:instance:6f6b16c6-0441-11ed-9541-0242ac120103"
},
{
"type": "Property",
"value": 76.0,
"modifiedAt": "2022-07-15T13:24:19.696Z",
"instanceId": "urn:ngsi-ld:attribute:instance:6ed1d326-0441-11ed-81be-0242ac120103"
}
],
"Error_info": {
"type": "Property",
"value": {
"type": "commandResult",
"#value": " "
},
"modifiedAt": "2022-07-15T13:21:24.893Z",
"instanceId": "urn:ngsi-ld:attribute:instance:06a2ec9a-0441-11ed-b967-0242ac120103"
}
}
]
Now I want to visualize time-series data using grafana. For QL + subscription this is documented very well (see here): We will have to use table 'et<entitytype>', time column 'time_index' and metric column 'entity_type'. I tested the scenario successfully using TimescaleDB.
Issue:
I can't find any information on how to visualize data with grafana using STH. TimescaleDB now has different tables for entities, attributes, subattributes and more. Using Grafana I am not sure how to query the entities correctly. Especially I have problems with the example above, where no observedAt but the modifiedAt property is being used as timeproperty.
So actually I am able to query timeseries data with the described STH infrastructure using orion-ld, but not to visualize them with grafana. Do you have recommendations on that?
Update:
to keep it more simple you could also use the sample from FIWARE instead of my custom example from above: https://github.com/FIWARE/tutorials.Short-Term-History
Just clone code, switch to branch NGSI-LD, add Grafana to the example in docker-compose:
...
grafana:
labels:
org.test: 'fiware'
image: grafana/grafana:6.1.6
container_name: grafana
networks:
default:
ipv4_address: 172.18.1.8
ports:
- "3003:3000"
... and start the example as described by ./services orion legacy. Afterwards open farm http://localhost:3000 and do some stuff (refill hay, water on, start tractor, ...)
If you query OCB you get temporal data easily. For example heartRate of cow002:
curl --location --request GET 'http://localhost:8080/temporal/entities/urn:ngsi-ld:Animal:cow002' \
--header 'NGSILD-Tenant: openiot' \
--header 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
--header 'attrs: heartRate'
Response:
{
"id": "urn:ngsi-ld:Animal:cow002",
"type": "Animal",
"heartRate": [
{
"type": "Property",
"value": 51.0,
"observedAt": "2022-09-26T13:37:25.823Z",
"instanceId": "urn:ngsi-ld:attribute:instance:5ba7d35c-3da0-11ed-a105-0242ac120109",
"unitCode": "5K",
"providedBy": {
"object": "urn:ngsi-ld:Device:cow002",
"type": "Relationship",
"instanceId": "urn:ngsi-ld:attribute:instance:5ba7d3fc-3da0-11ed-a105-0242ac120109"
}
},
{
"type": "Property",
"value": 52.0,
"observedAt": "2022-09-26T13:37:35.523Z",
"instanceId": "urn:ngsi-ld:attribute:instance:6184922e-3da0-11ed-abeb-0242ac120109",
"unitCode": "5K",
"providedBy": {
"object": "urn:ngsi-ld:Device:cow002",
"type": "Relationship",
"instanceId": "urn:ngsi-ld:attribute:instance:618492ce-3da0-11ed-abeb-0242ac120109"
}
},
{
"type": "Property",
"value": 51.0,
"observedAt": "2022-09-26T13:38:00.610Z",
"instanceId": "urn:ngsi-ld:attribute:instance:705e724c-3da0-11ed-a516-0242ac120109",
"unitCode": "5K",
"providedBy": {
"object": "urn:ngsi-ld:Device:cow002",
"type": "Relationship",
"instanceId": "urn:ngsi-ld:attribute:instance:705e72e2-3da0-11ed-a516-0242ac120109"
}
},
{
"type": "Property",
"value": 52.0,
"observedAt": "2022-09-26T13:38:15.597Z",
"instanceId": "urn:ngsi-ld:attribute:instance:794d239e-3da0-11ed-a8c0-0242ac120109",
"unitCode": "5K",
"providedBy": {
"object": "urn:ngsi-ld:Device:cow002",
"type": "Relationship",
"instanceId": "urn:ngsi-ld:attribute:instance:794d242a-3da0-11ed-a8c0-0242ac120109"
}
},
...
In timescale db you now can find tables for attributes, subattributes, entities and more stuff filled with some data. When I want to visualize the same example of cow002 and heartRate with grafana, I am not sure which table or tables I need to query. I am even not able to find the attribute heartRate in any of the tables.
Could you please assist how data can be visualized using grafana and Short Time History? Tutorials / Documentation don't mention how to visualize STH data with grafana with the different table structure. Maybe we can use the example of the heartRate to keep example simple.
Thank you in advance!
Yeah I finally found a solution and described it here in case of Scorpio: https://github.com/FIWARE/tutorials.Short-Term-History/issues/15
It is far more complicated to visualize data when you use STH instead of QL+subscriptions, but it is possible with more advanced Grafana queries.

How do I create a group tab on Kentico Kontent Management Api v2

So I have tried all sorts now.
I have tried this json
{
name: "Bla bla",
type: "group-tab",
external_id: "some_key_that_is_unique_gUID"
}
That did not work. It complains that group-tab is not a valid type. If I leave it off then it complains that the value is mandatory. The SDK allows me to omit the type.
How do I create a group and what is the valid type for a group tab.
I assume you want to create a content type with content groups, am I right?
If so, you need to send POST request to https://manage.kontent.ai/v2/projects/{project_id}/types with the body:
{
"external_id": "article",
"name": "Article",
"codename": "my_article",
"content_groups": [
{
"name": "Article copy",
"external_id": "article-copy"
},
{
"name": "Author",
"codename": "author"
}
],
"elements": [
{
"name": "Article title",
"codename": "title",
"type": "text",
"content_group": {
"external_id": "article-copy"
}
},
{
"name": "Article body",
"codename": "body",
"type": "rich_text",
"content_group": {
"external_id": "article-copy"
}
},
{
"name": "Author bio",
"codename": "bio",
"allowed_blocks": [
"images",
"text"
],
"type": "rich_text",
"content_group": {
"codename": "author"
}
}
]
}
Please note "content_groups":[...] field in the root of JSON as well as a specific content group for each element.
Also, do not forget to add auth header. You can find more info in the documentation.
Note: I assume (from your disclosed payload), the API is complaining correctly that group_tab is not a valid type, since you probably use the wrong endpoint - not sure here since you didn't post your whole request.
Creating a content group should occur while adding a new content type via the Management API v2 (documentation here: https://docs.kontent.ai/reference/management-api-v2#operation/add-a-content-type )
From the documentation example, "Article Copy" and "Author" content groups are added to the newly created "Article" content type, and the groups are referenced in each element to indicate which group the respective element should fall under.
In the example from the documentation, focus on:
"content_groups": [
{
"name": "Article copy",
"external_id": "article-copy"
},
{
"name": "Author",
"codename": "author"
}
],
in data and:
"content_group": {
"external_id": "article-copy"
}
for each element in the elements array.
curl --request POST \
--url https://manage.kontent.ai/v2/projects/<YOUR_PROJECT_ID>/types
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Content-type: application/json' \
--data '
{
"external_id": "article",
"name": "Article",
"codename": "my_article",
"content_groups": [
{
"name": "Article copy",
"external_id": "article-copy"
},
{
"name": "Author",
"codename": "author"
}
],
"elements": [
{
"name": "Article title",
"codename": "title",
"type": "text",
"content_group": {
"external_id": "article-copy"
}
},
{
"name": "Article body",
"codename": "body",
"type": "rich_text",
"content_group": {
"external_id": "article-copy"
}
},
{
"name": "Author bio",
"codename": "bio",
"allowed_blocks": [
"images",
"text"
],
"type": "rich_text",
"content_group": {
"codename": "author"
}
}
]
}'

503 Response Error Code - Using Graph API For Indexing Data against Microsoft Search

I have no clue as to why this is happening for this API only. I am getting 503 service unavailable. Can someone please help me in this.
Payload Used:
{
"#odata.type": "microsoft.graph.externalItem",
"acl": [
{
"type": "user",
"value": "****Azure Object ID***",
"accessType": "grant",
"identitySource": "azureActiveDirectory"
},
{
"type": "user",
"value": "*****AZURE OBJECT ID******",
"accessType": "grant",
"identitySource": "azureActiveDirectory"
}
],
"properties": {
"Product": "Product created in manual",
"Company": "ITC Infotech",
"Category": "Mobile",
"Description" : "this is just a dummy description",
"Price": "$20.22",
"HomePage": "https://www.google.com",
"Image": "https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/gardenia-royalty-free-image-1580854928.jpg?crop=1xw:1xh;center,top&resize=480:*"
},
"content": {
"value": "this is just a dummy description",
"type": "text"
}
}
Looks like you need to add /external/connections. Please look at this document.

Yodlee addSiteAccount1 failing to register accounts with "Exception Occurred" message

I have been trying to get the addSiteAccount1 API endpoint to accept the data I am sending it.
According to the documentation I have set out the structure below.
The first structure I tried used an array for the current credentialsField object, but I couldn't set "enclosedType" of the credentialFields array... so that was scrapped in favour of an object with numbered keys.
{
"cobSessionToken": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"userSessionToken": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"siteId": 4252,
"credentialFields": {
"0": {
"displayName": "Customer Number(DOB (ddmmyy) followed by unique number)",
"fieldType": {
"typeName": "IF_LOGIN"
},
"name": "LOGIN",
"valueMask": "LOGIN_FIELD",
"isEditable": true,
"valueIdentifier": "LOGIN",
"value": "123456789"
},
"1": {
"displayName": "Security Number",
"fieldType": {
"typeName": "IF_PASSWORD"
},
"name": "PASSWORD",
"valueMask": "LOGIN_FIELD",
"isEditable": true,
"valueIdentifier": "PASSWORD",
"value": "123456789"
},
"2": {
"displayName": "Password",
"fieldType": {
"typeName": "IF_PASSWORD"
},
"name": "PASSWORD1",
"valueMask": "LOGIN_FIELD",
"isEditable": true,
"valueIdentifier": "PASSWORD1",
"value": "password123"
},
"enclosedType": "com.yodlee.common.FieldInfoSingle"
}
}
Unfortunately, I only ever get the following response from Yodlee, which hasn't helped very much. If anyone can see where I'm going wrong it would be much appreciated.
{
"errorOccurred": "true",
"exceptionType": "Exception Occurred",
"referenceCode": "_f2d54a4c-f328-418e-b9fd-cec0be18f5e1"
}
Thanks in advance.
You are facing the same problem as this post , please see the answer and follow it.

Resources