Delay in getting Google Fit API Response - google-api

I am using GoogleFit API to fetch the data I have added in the Gooogle Fit app, but it takes around 30 mins or so to get that data reflected in the API response.
API:
https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate
Request Body
{
"aggregateBy": [{
"dataTypeName": "com.google.blood_glucose"
},
{
"dataTypeName": "com.google.blood_pressure"
},
{
"dataTypeName": "com.google.heart_rate.bpm"
}],
"startTimeMillis": 1645446600000,
"endTimeMillis": 1645533000000
}
Response Body
{
"bucket": [
{
"startTimeMillis": "1645446600000",
"endTimeMillis": "1645533000000",
"dataset": [
{
"dataSourceId": "derived:com.google.blood_glucose:com.google.android.gms:merged",
"point": []
},
{
"dataSourceId": "derived:com.google.blood_pressure:com.google.android.gms:merged",
"point": []
},
{
"dataSourceId": "derived:com.google.heart_rate.bpm:com.google.android.gms:merge_heart_rate_bpm",
"point": []
}
]
}
]
}

Related

Is there an alternative to receiving activity data that isn't aggregated from Google Fit's REST API?

I am trying to get specific data that relates to individual activities.
I can retrieve all data relating to all activities that were performed within a time frame (day).
However it is not specific as to which dataset belongs to which activity i.e. there is no identifier.
It does not come back in order either.
I tried grouping by 'StartTimeNanos' but that is not a solid solution as the data is in random order too.
Is there an alternative way to get back activity specific data?
I completed the following activities:
Google fit walk activity
Google fit run activity
and after making the following http GET request to : https://fitness.googleapis.com/fitness/v1/users/me/dataSources.
It returns all datatSources for user {me} : as 'source'.
I then use all sources mapped to the objects:
{ "dataTypeName": "source.dataTypeName", "dataSourceId": "source.dataSourceId" }
I then pass it in the body of the call to: https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate
and the response is the following (with deleted values for readability here) :
{
"bucket": [
{
"startTimeMillis": "1673136000000",
"endTimeMillis": "1673215200000",
"dataset": [
{
"dataSourceId": "derived:com.google.active_minutes:com.google.android.gms:aggregated",
"point": [
{
"startTimeNanos": "1673176860000000000",
"endTimeNanos": "1673200740000000000",
"dataTypeName": "com.google.active_minutes",
"originDataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps",
"value": [
{
"intVal": 103,
"mapVal": []
}
]
}
]
},
{
"dataSourceId": "derived:com.google.activity.summary:com.google.android.gms:aggregated",
"point": [
{
"startTimeNanos": "1673176862610000000",
"endTimeNanos": "1673181480270000000",
"dataTypeName": "com.google.activity.summary",
"originDataSourceId": "raw:com.google.activity.segment:nl.appyhapps.healthsync:running",
"value": [
{
"intVal": 8,
"mapVal": []
},
{
"intVal": 4564870,
"mapVal": []
},
{
"intVal": 2,
"mapVal": []
}
]
},
{
"startTimeNanos": "1673199914195000000",
"endTimeNanos": "1673200789933000000",
"dataTypeName": "com.google.activity.summary",
"originDataSourceId": "derived:com.google.activity.segment:nl.appyhapps.healthsync:session_activity_segment",
"value": [
{
"intVal": 7,
"mapVal": []
},
{
"intVal": 875738,
"mapVal": []
},
{
"intVal": 1,
"mapVal": []
}
]
}
]
},
{
"dataSourceId": "derived:com.google.distance.delta:com.google.android.gms:aggregated",
"point": [
{
"startTimeNanos": "1673176936608000000",
"endTimeNanos": "1673181472006000000",
"dataTypeName": "com.google.distance.delta",
"originDataSourceId": "derived:com.google.distance.delta:com.google.android.gms:from_high_accuracy_location<-derived:com.google.location.sample:com.google.android.gms:merge_high_fidelity",
"value": [
{
"fpVal": 11273.688227319104,
"mapVal": []
}
]
}
]
},
{
"dataSourceId": "derived:com.google.distance.delta:com.google.android.gms:aggregated",
"point": [
{
"startTimeNanos": "1673176800000000000",
"endTimeNanos": "1673200789933000000",
"dataTypeName": "com.google.distance.delta",
"originDataSourceId": "raw:com.google.distance.delta:com.sec.android.app.shealth:health_platform",
"value": [
{
"fpVal": 14075.092156685667,
"mapVal": []
}
]
}
]
},
As you can see, there is no way of identifying which point maps to which activity.

INDEXER Lake Framework - outcome.status.failure not showing execution error

The following transaction
https://explorer.near.org/transactions/CkZYiXB3BEoXNuLDqcn5GjErkXghKGCB47yPyyze4kTf#BPYU8T3o5mdsU4ewG3JdCLRe8ivpsGTehKxkifFAsboD
failed whith the following error:
{
"type": "action",
"error": {
"type": "functionCallError",
"error": {
"type": "executionError",
"error": "Smart contract panicked: The contract is not initialized"
}
}
}
But what I got on the indexer is the following:
{
"outcome":{
"executionOutcome":{
"blockHash":"8NP4Z2i7CBQzRUxa8CfuummnYZvwfZaCFmif4d6mcgyB",
"id":"CkZYiXB3BEoXNuLDqcn5GjErkXghKGCB47yPyyze4kTf",
"outcome":{
"executorId":"test1.csandi.near",
"gasBurnt":2428211671420,
"logs":[
],
"metadata":{
"gasProfile":null,
"version":1
},
"receiptIds":[
"GrXdFKA9byvCmxGiQkGc9iaFn88FfePk4tfJhvcTGMwc"
],
"status":{
"SuccessReceiptId":"GrXdFKA9byvCmxGiQkGc9iaFn88FfePk4tfJhvcTGMwc"
},
"tokensBurnt":"242821167142000000000"
},
"proof":[
{
"direction":"Left",
"hash":"BWhmGBmvzbX3WBP1RZQ59DB749sHSV2xS5pNyF6xAbbh"
},
{
"direction":"Right",
"hash":"H4YMDcd9Fh68KTwyPTwYuFb89KhfdGUoxRbBYzDcNAze"
},
{
"direction":"Right",
"hash":"9jv152euKvurdVkDYS5FKiiT4ej6xL1gRYTHoNbjwEZi"
},
{
"direction":"Right",
"hash":"BqQFHzSYzqDE8tMQkJT8PHFGxLmQrkFBcuTqFP4nTjx7"
}
]
},
"receipt":null
},
"transaction":{
"actions":[
{
"FunctionCall":{
"args":"eyJpbml0aWFsX3ByaWNlIjoxLjksInNwYWNpbmciOjIsImFscGhhX2lkIjoidXNuIiwiYmV0YV9pZCI6IndyYXAubmVhciIsInN3YXBfZmVlX3JhdGUiOjAuMDAzLCJwcm90b2NvbF90b2xsIjowLjAxfQ==",
"deposit":"0",
"gas":200000000000000,
"methodName":"create_new_pool"
}
}
],
"hash":"CkZYiXB3BEoXNuLDqcn5GjErkXghKGCB47yPyyze4kTf",
"nonce":75627675000007,
"publicKey":"ed25519:85yAx5mY8DinTWQfMn47cZTHMhZtLRAWZLpazYmetwno",
"receiverId":"dev-cliquidity-perk-jorge.near",
"signature":"ed25519:1CieS8AUSc7Y3S8By8adJaEXXydXcjvSA1uVXPgrdhkmGPpf5ykA7XWqJGZnDhMtymkp6eWDBEQzsBXkhybAbUV",
"signerId":"test1.csandi.near"
}
}
So I would like to know if there is anyway to get the failure message from the indexer?
Look in the next blocks for the corresponding receipt from the SuccessReceiptId (id GrXdFKA9byvCmxGiQkGc9iaFn88FfePk4tfJhvcTGMwc), and in its execution outcome you will find that status.
I cannot recommend more to watch or read the Data Flow in NEAR
FYI, just to follow up and clarify for anyone with this question, after following the above response by "Vlad Frolov", in order to get the Receipt Status, I had to check
shard.receiptExecutionOutcomes
which will provide the results of the receipts, so I started to track the receipts that I am interested in, in this case for
SuccessReceiptId (GrXdFKA9byvCmxGiQkGc9iaFn88FfePk4tfJhvcTGMwc)
"executionOutcome":{
"blockHash":"59F5pES9Myc2VT4JkppE95epCwtGAXYux9okbzpsh95K",
"id":"**GrXdFKA9byvCmxGiQkGc9iaFn88FfePk4tfJhvcTGMwc**",
"outcome":{
"executorId":"dev-cliquidity-perk-jorge.near",
"gasBurnt":2824274578054,
"logs":[
],
"metadata":{
"gasProfile":[
{
"cost":"BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"1323840555"
},
{
"cost":"CONTRACT_LOADING_BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"35445963"
},
{
"cost":"CONTRACT_LOADING_BYTES",
"costCategory":"WASM_HOST_COST",
"gasUsed":"106584645000"
},
{
"cost":"READ_MEMORY_BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"5219726400"
},
{
"cost":"READ_MEMORY_BYTE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"136847988"
},
{
"cost":"READ_REGISTER_BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"2517165186"
},
{
"cost":"READ_REGISTER_BYTE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"11334630"
},
{
"cost":"STORAGE_READ_BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"56356845750"
},
{
"cost":"STORAGE_READ_KEY_BYTE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"154762665"
},
{
"cost":"TOUCHING_TRIE_NODE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"193223471112"
},
{
"cost":"UTF8_DECODING_BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"3111779061"
},
{
"cost":"UTF8_DECODING_BYTE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"9038994849"
},
{
"cost":"WASM_INSTRUCTION",
"costCategory":"WASM_HOST_COST",
"gasUsed":"11928316488"
},
{
"cost":"WRITE_MEMORY_BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"2803794861"
},
{
"cost":"WRITE_MEMORY_BYTE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"313233780"
},
{
"cost":"WRITE_REGISTER_BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"2865522486"
},
{
"cost":"WRITE_REGISTER_BYTE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"437179860"
}
],
"version":1
},
"receiptIds":[
"BPYU8T3o5mdsU4ewG3JdCLRe8ivpsGTehKxkifFAsboD"
],
**"status":{
"Failure":{
"ActionError":{
"index":0,
"kind":{
"FunctionCallError":{
"ExecutionError":"Smart contract panicked: The contract is not initialized"
}
}
}
}**
},
"tokensBurnt":"282427457805400000000"
},
"proof":[
{
"direction":"Left",
"hash":"5j1RhLnf5jGChUPxU9CPNbAGwSn6VnzBw7taJe5vSnYD"
},
{
"direction":"Right",
"hash":"AJ2kARUcYAkzsL3xmw4jAETZ61jtQuswf7RvhSxscKCR"
},
{
"direction":"Left",
"hash":"9vXQjFdTaQw5XjUKsRK6N3WFCg5zMVca5Ze2Qqznn3AM"
}
] }, "receipt":{
"predecessorId":"test1.csandi.near",
"receipt":{
"Action":{
"actions":[
{
"FunctionCall":{
"args":"eyJpbml0aWFsX3ByaWNlIjoxLjksInNwYWNpbmciOjIsImFscGhhX2lkIjoidXNuIiwiYmV0YV9pZCI6IndyYXAubmVhciIsInN3YXBfZmVlX3JhdGUiOjAuMDAzLCJwcm90b2NvbF90b2xsIjowLjAxfQ==",
"deposit":"0",
"gas":200000000000000,
"methodName":"create_new_pool"
}
}
],
"gasPrice":"346069590",
"inputDataIds":[
],
"outputDataReceivers":[
],
"signerId":"test1.csandi.near",
"signerPublicKey":"ed25519:85yAx5mY8DinTWQfMn47cZTHMhZtLRAWZLpazYmetwno"
}
},
"receiptId":"GrXdFKA9byvCmxGiQkGc9iaFn88FfePk4tfJhvcTGMwc",
"receiverId":"dev-cliquidity-perk-jorge.near" } }
And as you can see in the json response,the following status:
"status":{
"Failure":{
"ActionError":{
"index":0,
"kind":{
"FunctionCallError":{
"ExecutionError":"Smart contract panicked: The contract is not initialized"
}
}
}
}
Anyway to fully understand how transactions/receipts work this document helped a lot.

Dynamics 365 Search Resource Availability With Constraints

I've been trying to add filters to my Search Resource Availability api call following this page: Search resource availability API
No matter what I do I can't seem to filter by Organizational Unit.
Here's my http call body:
{
"Version": "3",
"IsWebApi": true,
"Requirement": {
"msdyn_fromdate": "2021-11-01T00:00:00Z",
"msdyn_todate": "2021-11-30T23:59:00Z",
"msdyn_remainingduration": 60,
"msdyn_duration": 60,
"#odata.type": "Microsoft.Dynamics.CRM.msdyn_resourcerequirement"
},
"Settings": {
"ConsiderSlotsWithProposedBookings": false,
"MovePastStartDateToCurrentDate": true,
"#odata.type": "Microsoft.Dynamics.CRM.expando"
},
"ResourceSpecification":{
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"ResourceTypes#odata.type": "Collection(Microsoft.Dynamics.CRM.expando)",
"ResourceTypes": [
{
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"value": "3"
}
],
"Constraints": {
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"OrganizationalUnits#odata.type": "Collection(Microsoft.Dynamics.CRM.expando)",
"OrganizationalUnits":[
{
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"value": "b2054232-a114-ec11-b6e7-000d3a842ab8"
}
]
}
}
}
And here's the response I get:
{
"#odata.context": "https://orga215da53.api.crm3.dynamics.com/api/data/v9.2/$metadata#Microsoft.Dynamics.CRM.msdyn_SearchResourceAvailabilityResponse",
"TimeSlots": [],
"Resources": [],
"Related": {
"#odata.type": "#Microsoft.Dynamics.CRM.expando",
"TimeSlots#odata.type": "#Collection(Microsoft.Dynamics.CRM.crmbaseentity)",
"TimeSlots": [],
"Resources#odata.type": "#Collection(Microsoft.Dynamics.CRM.crmbaseentity)",
"Resources": []
},
"Exceptions": {
"#odata.type": "#Microsoft.Dynamics.CRM.expando"
}
}
But i KNOW that that organization unit exists in CRM.
I tried changing the odata.type to the actual Organization Unit CRM type (msdyn_organizationalunit) but that just gives me an error (An error occurred while validating input parameters: System.ArgumentNullException: Value cannot be null)
What is it that I'm doing wrong?
Thanks!
Good day,
I'm not sure but maybe "Constraints" should be outside "ResourceSpecification" like:
{
"Version": "3",
"IsWebApi": true,
"Requirement": {
"msdyn_fromdate": "2021-11-01T00:00:00Z",
"msdyn_todate": "2021-11-30T23:59:00Z",
"msdyn_remainingduration": 60,
"msdyn_duration": 60,
"#odata.type": "Microsoft.Dynamics.CRM.msdyn_resourcerequirement"
},
"Settings": {
"ConsiderSlotsWithProposedBookings": false,
"MovePastStartDateToCurrentDate": true,
"#odata.type": "Microsoft.Dynamics.CRM.expando"
},
"ResourceSpecification":{
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"ResourceTypes#odata.type": "Collection(Microsoft.Dynamics.CRM.expando)",
"ResourceTypes": [
{
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"value": "3"
}
]
},
"Constraints": {
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"OrganizationalUnits#odata.type": "Collection(Microsoft.Dynamics.CRM.expando)",
"OrganizationalUnits":[
{
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"value": "b2054232-a114-ec11-b6e7-000d3a842ab8"
}
]
}
}

Adaptive Cards Input Toggle(CheckBox) IOS issue

We have created bot using Microsoft bot-framework which is integrated to Microsoft teams. We have created few adaptive cards for interactive conversation with bot. One of the Adaptive card is causing design issue in IPhone X Microsoft Teams Application.
We used Adaptive card template for building this card which displays the list of Tasks along with status of the task. Each task has Input.Toggle (Checkbox) and at the end a button will be displayed. When Checkbox's are selected and button is clicked
We are sending new card with task details where they can edit the status and so on. Please find the JSON data below.
Card Payload Editor Json Data:
{
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "Container",
"border": true,
"items": [
{
"$data": "{properties}",
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "auto",
"items": [
{
"id": "{id}",
"type": "Input.Toggle",
"title": " ",
"value": "false",
"wrap": false
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "Container",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{peers}",
"title": "{key}",
"value": "{value}"
}
]
}
],
"style": "emphasis"
}
]
}
]
}
]
}
],
"actions": [
{
"type": "Action.Submit",
"title": "{actionSubmitTitle}",
"horizontalAlignment": "center"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
Sample Data Editor:
"properties":[
{
"id":"InputToggle1",
"peers":[
{
"key":"Project",
"value":"' .$task->project_name. '"
},
{
"key":"Task",
"value":"'.$task->id.' - '.$task->heading.'"
},
{
"key":"Status",
"value":"'.$task->board_column.'"
}
]
},
{
"id":"InputToggle2",
"peers":[
{
"key":"Project",
"value":"' .$task->project_name. '"
},
{
"key":"Task",
"value":"'.$task->id.' - '.$task->heading.'"
},
{
"key":"Status",
"value":"'.$task->board_column.'"
}
]
},
{
"id":"InputToggle3",
"peers":[
{
"key":"Project",
"value":"' .$task->project_name. '"
},
{
"key":"Task",
"value":"'.$task->id.' - '.$task->heading.'"
},
{
"key":"Status",
"value":"'.$task->board_column.'"
}
]
},
{
"id":"InputToggle4",
"peers":[
{
"key":"Project",
"value":"' .$task->project_name. '"
},
{
"key":"Task",
"value":"'.$task->id.' - '.$task->heading.'"
},
{
"key":"Status",
"value":"'.$task->board_column.'"
}
]
}
],
"actionSubmitTitle":"Update Timesheet"
}
The InputToggle is inside the column set with width as auto and it is perfectly rendering in Microsoft Desktop and Android App but whereas in IOS app it is not showing
When we set the width property to stretch, InputToggle is getting displayed in IOS App in big size but in Desktop App and Android App the column is pushing and occupying much space.
Please help me so that we can display the Input.Toggle in IOS Microsoft Teams without breaking the design in Desktop and Android Teams App.
Edit: Adding final JSON sent to the bot. The columns in the column set will be changed dynamically based on the ask list in database.
{
"type":"AdaptiveCard",
"version":"1.0",
"body":[
{
"type":"Container",
"border":true,
"items":[
{
"type":"ColumnSet",
"columns":[
{
"type":"Column",
"width":"auto",
"items":[
{
"id":"inputToggle1",
"type":"Input.Toggle",
"title":" ",
"value":"false",
"wrap":false
}
]
},
{
"type":"Column",
"width":"stretch",
"items":[
{
"type":"Container",
"items":[
{
"type":"FactSet",
"facts":[
{
"title":"Project",
"value":"Project 1"
},
{
"title":"Task",
"value":"Task 1"
},
{
"title":"Status",
"value":"Pending"
}
]
}
],
"style":"emphasis"
}
]
}
]
},
{
"type":"ColumnSet",
"columns":[
{
"type":"Column",
"width":"auto",
"items":[
{
"id":"inputToggle2",
"type":"Input.Toggle",
"title":" ",
"value":"false",
"wrap":false
}
]
},
{
"type":"Column",
"width":"stretch",
"items":[
{
"type":"Container",
"items":[
{
"type":"FactSet",
"facts":[
{
"title":"Project",
"value":"Project 1"
},
{
"title":"Task",
"value":" Task 2"
},
{
"title":"Status",
"value":"Completed"
}
]
}
],
"style":"emphasis"
}
]
}
]
}
]
}
],
"actions":[
{
"type":"Action.Submit",
"title":"Update Timesheet",
"horizontalAlignment":"center"
}
],
"$schema":"http://adaptivecards.io/schemas/adaptive-card.json"
}
Thank you.
For completion, this was caused by a bug and is tracked as an Github Issue here:
https://github.com/microsoft/AdaptiveCards/issues/4052#

Date math in elastic watcher email

I would like to find the datetime for 1 day ago so that I can create link to kibana in an email sent from the watcher. Using Elasticsearch 5.0.2
I've tried the watch below but it returns an error of
ScriptException[runtime error]; nested: IllegalArgumentException[Unable to find dynamic method [minusDays] with [1] arguments for class [org.joda.time.DateTime].];
minusDays does exist in the joda DateTime spec
but it doesn't exist in the elastic codebase
here's the watch
PUT /_xpack/watcher/watch/errors-prod
{
"trigger": {
"schedule": {
"daily": {
"at": [
"08:36"
]
}
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"<das-logstash-{now}>",
"<das-logstash-{now-1d}>"
],
"types": [
"redis-input"
],
"body": {
"size": 0,
"query": {
"match_all": {}
}
}
}
}
},
"actions": {
"send_email": {
"transform": {
"script" : "return [ 'from' : ctx.trigger.scheduled_time.minusDays(1) ]"
},
"email": {
"profile": "standard",
"from": "noreply#email.com",
"to": [
"me#email.com"
],
"subject": "errors",
"body": {
"html": "<html><body><p>from {{ctx.payload.from}}</p><p>to {{ctx.trigger.scheduled_time}}</p></body></html>"
}
}
}
}
}
I needed something similar and was able to hack this together by modifying a comment that almost worked from an elastic forum.
"transform": {
"script" : {
"source" : "def payload = ctx.payload; DateFormat df = new SimpleDateFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\"); ctx.payload.from = df.format(Date.from(Instant.ofEpochMilli(ctx.execution_time.getMillis() - (24 * 60 * 60 * 1000) ))); return payload"
}
},
Hope that helps!

Resources