Microsoft Graph curl to Excel online - microsoft-graph-api

I have an Excel on-line spreadsheet. It's sits on my company's OneDrive.
I'd like to ask is it possible to get value of the specific cell (with formula in it) using Microsoft Graph and simple curl from bash?

The answer is yes. It is possible to get value of the specific cell (with formula in it) using Microsoft Graph and simple curl from bash.
Try the following endpoint:
GET
/{version}/me/drive/items/{item-id}/workbook/worksheets/{worksheet-id}/range(address='A1:B2')
authorization: Bearer {access-token} workbook-session-id:
{session-id}
My test request endpoint:
https://graph.microsoft.com/v1.0/me/drive/root:/test.xlsx:/workbook/mysheet/range(address='c1')
Response
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#workbookRange",
"#odata.type": "#microsoft.graph.workbookRange",
"#odata.id": "/me/drive/root/workbook/worksheets(guid)/range(address=%27c1%27)",
"address": "Sheet1!C1",
"addressLocal": "Sheet1!C1",
"cellCount": 1,
"columnCount": 1,
"columnHidden": false,
"columnIndex": 2,
"formulas": [
[
"=SUM(D1,E1)"
]
],
"formulasLocal": [
[
"=SUM(D1,E1)"
]
],
"formulasR1C1": [
[
"=SUM(RC[1],RC[2])"
]
],
"hidden": false,
"numberFormat": [
[
"General"
]
],
"rowCount": 1,
"rowHidden": false,
"rowIndex": 0,
"text": [
[
"3"
]
],
"values": [
[
3
]
],
"valueTypes": [
[
"Double"
]
]
}

Related

Microsoft graph table api not returning column values in its date format

I'm retrieving data from Microsoft workbook/excel file's table.
Workbook's table has date-of-birth column which has date format.
While retrieving values using Microsoft graph's table api it returns dates as some integer value.
API i'm using:
https://graph.microsoft.com/v1.0/me/drive/root:/book.xlsx:/workbook/tables/table4/columns
Microsoft graph API reference : https://learn.microsoft.com/en-us/graph/api/table-list-columns?view=graph-rest-1.0&tabs=http
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('<user_id>')/drive/root/workbook/tables('table4')/columns",
"value": [
{
"#odata.id": "/users('<user_id>')/drive/root/workbook/tables(%27%7BF44C7573-9BBE-46F3-B0BE-C5607762D2AB%7D%27)/columns(%271%27)",
"values": [
[
"Name"
],
[
"Student 1"
],
[
"Student 2"
]
],
"id": "1",
"index": 0,
"name": "Name"
},
{
"#odata.id": "/users('<user_id>')/drive/root/workbook/tables(%27%7BF44C7573-9BBE-46F3-B0BE-C5607762D2AB%7D%27)/columns(%273%27)",
"values": [
[
"DOB"
],
[
35339
],
[
34249
]
],
"id": "3",
"index": 1,
"name": "DOB"
}
]
}
Original values are
Is there any way to get date values in its original format
The endpoint you are using
GET /me/drive/root:/book.xlsx:/workbook/tables/table4/columns
returns workbookTableColumn resource type which has only information about raw values without information about data type and formatting.
You can use id or name of workbookTableColumn and call dataBodyRange endpoint
GET /me/drive/root:/{item-path}:/workbook/tables/{id|name}/columns/{columnId|columnName}/dataBodyRange
GET /me/drive/root:/book.xlsx:/workbook/tables/{id|name}/columns/{columnId|columnName}/dataBodyRange
which returns range resource type.
Range resource type has property text which represents text values of the specified range.
...
"text": [
[
"09.06.2022"
],
[
""
]
],
...

Youtube analytics API return incomplete data

I've been using youtube analytics API to fetch different reports, but since some days ago the api is not returning complete data, but only until 3 days before the current date.
The following is a request for video views report from 2020-04-20 until 2020-04-28, but the response returns data only until 2020-04-25, but I can see in my channel that we have video views in the dates 2020-04-26 and 2020-04-27.
'https://youtubeanalytics.googleapis.com/v2/reports?dimensions=day%2CinsightTrafficSourceType&endDate=2020-04-28&filters=video%3D%3DoQqVWPfSfe8&ids=channel%3D%3DMINE&metrics=views%2CestimatedMinutesWatched&sort=day%2C-views&startDate=2020-04-20&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
Response:
{
"kind": "youtubeAnalytics#resultTable",
"columnHeaders": [
{
"name": "day",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "insightTrafficSourceType",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "views",
"columnType": "METRIC",
"dataType": "INTEGER"
},
{
"name": "estimatedMinutesWatched",
"columnType": "METRIC",
"dataType": "INTEGER"
}
],
"rows": [
[
"2020-04-20",
"ADVERTISING",
23429,
12417
],
[
"2020-04-20",
"NO_LINK_OTHER",
31,
5
],
[
"2020-04-20",
"EXT_URL",
5,
0
],
[
"2020-04-21",
"ADVERTISING",
46469,
24522
],
[
"2020-04-21",
"NO_LINK_OTHER",
54,
9
],
[
"2020-04-21",
"EXT_URL",
5,
1
],
[
"2020-04-22",
"ADVERTISING",
40020,
21132
],
[
"2020-04-22",
"NO_LINK_OTHER",
43,
9
],
[
"2020-04-22",
"EXT_URL",
7,
2
],
[
"2020-04-23",
"ADVERTISING",
22944,
12127
],
[
"2020-04-23",
"NO_LINK_OTHER",
32,
6
],
[
"2020-04-23",
"EXT_URL",
3,
0
],
[
"2020-04-24",
"ADVERTISING",
8549,
4524
],
[
"2020-04-24",
"NO_LINK_OTHER",
42,
9
],
[
"2020-04-24",
"EXT_URL",
7,
3
],
[
"2020-04-25",
"ADVERTISING",
820,
432
],
[
"2020-04-25",
"NO_LINK_OTHER",
30,
3
],
[
"2020-04-25",
"EXT_URL",
8,
1
]
]
}
Has something changed in the API? any new restrictions?
Thank you for your support.

HighCharts not displaying series data

I have a timeseries data which I am trying to display with Highstocks:
Here is the data:
{
"title": {
"text": "My Graph"
},
"series": [
[
{
"name": "Future Index Longs",
"data": [
[
"2019-02-05",
104516
],
[
"2019-02-06",
127260
],
[
"2019-02-07",
156291
],
[
"2019-02-08",
167567
]
]
}
],
[
{
"name": "Future Index Longs",
"data": [
[
"2019-02-05",
21
],
[
"2019-02-06",
0
],
[
"2019-02-07",
1263
],
[
"2019-02-08",
12
]
]
}
],
[
{
"name": "Future Index Longs",
"data": [
[
"2019-02-05",
33873
],
[
"2019-02-06",
61093
],
[
"2019-02-07",
43125
],
[
"2019-02-08",
41928
]
]
}
],
[
{
"name": "Future Index Longs",
"data": [
[
"2019-02-05",
47542
],
[
"2019-02-06",
55084
],
[
"2019-02-07",
75256
],
[
"2019-02-08",
77786
]
]
}
],
[
{
"name": "Future Index Longs",
"data": [
[
"2019-02-05",
185952
],
[
"2019-02-06",
243437
],
[
"2019-02-07",
275935
],
[
"2019-02-08",
287293
]
]
}
]
]
}
The graph is empty and no data is displayed. What am I doing wrong?
Sorry to add this filler here but I am required to add more text to post this question and since this is a pretty simple question, I don't have much to add.
You have the wrong format on your series, it should be an array of objects.
Like this: series: [{ ... }, { ... }]
Check this fiddle: https://jsfiddle.net/wg1vnyzp/1/
To have a chart with datetime axes in Highcharts you have to pass the X value as the timestamp in milliseconds since 1970.
Highstock example:
https://jsfiddle.net/BlackLabel/f0rsz6cd/1/
Note that in Highcharts you have to define xAxis.type as datetime like that:
xAxis: {
type: 'datetime'
}
Highcharts demo:
https://jsfiddle.net/BlackLabel/kas2oywp/
API reference:
https://api.highcharts.com/highcharts/series.line.data.x
https://api.highcharts.com/highcharts/xAxis.type

groupBy not grouping by a tag created with eval after a join

Full details of your operating system (or distribution) e.g. 64-bit Ubuntu 14.04.
Running InfluxDB/Kapacitor/Chronograf as Docker containers on MacOSX, latest Docker.
The version of Kapacitor you are running
Latest, 1.4.
Whether you installed it using a pre-built package, or built it from source.
Official Docker container
We are running into an issue with TICKscript and its groupBy behaviour.
We have two sets of measurements, indoor_temperatures and outdoor_temperatures, which we query with a batch.
The queries look as follows:
var out_temp = batch
|query('SELECT mean(temperature) FROM yyyy')
.every(10s)
.period(120d)
.groupBy(time(1h))
.fill(0)
var in_temp = batch
|query('SELECT mean(temperature) FROM xxxx')
.every(10s)
.period(120d)
.groupBy(time(1h))
.fill(0)
If we HTTP out both of them, they create the following sets of data:
{
"series": [
{
"name": "outdoor_temperatures",
"columns": [
"time",
"mean"
],
"values": [
[
"2017-09-20T17:00:00Z",
0
],
[
"2017-09-20T18:00:00Z",
11.5
]
... the rest
]
}
]
}
{
"series": [
{
"name": "indoor_measurements",
"columns": [
"time",
"mean"
],
"values": [
[
"2017-09-20T17:00:00Z",
585.44012944984
],
[
"2017-09-20T18:00:00Z",
592.94890510949
]
... the rest
]
}
]
}
Now we do a full join of them, which gives us expected results
out_temp
|join(in_temp)
.as('out_temp_mean', 'in_temp_mean')
.tolerance(5m)
.fill(0)
httpOut:
{
"series": [
{
"name": "outdoor_temperatures",
"columns": [
"time",
"in_temp_mean.mean",
"out_temp_mean.mean"
],
"values": [
[
"2017-09-20T17:00:00Z",
586.10175438596,
0
],
[
"2017-09-20T18:00:00Z",
592.94890510949,
11.5
]
... the rest
]
}
]
}
Which looks perfect. The issue raises when we want to round the out_temp_mean.mean down and groupBy it
So we go ahead and extend the script
out_temp
|join(in_temp)
.as('out_temp_mean', 'in_temp_mean')
.tolerance(5m)
.fill(0)
|eval(lambda: string(floor("out_temp_mean.mean")))
.as('bucket')
.tags('bucket')
.keep('out_temp_mean.mean', 'in_temp_mean.mean')
After which the output STILL looks as it should:
{
"series": [
{
"name": "outdoor_temperatures",
"columns": [
"time",
"in_temp_mean.mean",
"out_temp_mean.mean",
"bucket"
],
"values": [
[
"2017-09-20T17:00:00Z",
586.99190283401,
0,
"0"
],
[
"2017-09-20T18:00:00Z",
592.94890510949,
11.5,
"11"
]
]
}
]
}
Now only thing left is to group the values by the new tag bucket:
out_temp
|join(in_temp)
.as('out_temp_mean', 'in_temp_mean')
.tolerance(5m)
.fill(0)
|eval(lambda: string(floor("out_temp_mean.mean")))
.as('bucket')
.tags('bucket')
.keep('out_temp_mean.mean', 'in_temp_mean.mean')
|groupBy('bucket')
After which everything goes awry and we are greeted with series: null
{
"series": null
}
Is this expected behaviour? A bug? Or something else?
Also filed this as https://github.com/influxdata/kapacitor/issues/1765 if someone wonders.

How do i create long/big Dictionaries in Swift? Error: Expression was to complex to be solved in reasnoble time

So i have this piece of code (fieldKey is a String)
var request = [
"size": 0,
"aggs": [
fieldKey : [
"global": [],
"aggs": [
"global": [
"aggs": [
"facet": [
"nested": [
"path": "tags"
],
"aggs": [
"bar": [
"filter": [
"match": [
"tags.name": fieldKey
]
]
],
"aggs": [
"filtered": [
"terms": [
"field": "tags.name"
],
"aggs": [
"values": [
"terms": [
"field": "tags.value.raw",
"min_doc_count": 1
]
]
]
]
]
]
]
]
]
]
]
]
]
Im trying to create a JSON request for Elasticsearch server.
I get the "Expression was to complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions" error.
This is when i tried to do this.
var request = [
"size": 0,
"aggs": [String : AnyObject]()
]
request["aggs"]![fieldKey] = [
fieldKey : [
"global": [],
"aggs": [
"global": [
"aggs": [
"facet": [
"nested": [
"path": "tags"
],
"aggs": [
"bar": [
"filter": [
"match": [
"tags.name": fieldKey
]
]
],
"aggs": [
"filtered": [
"terms": [
"field": "tags.name"
],
"aggs": [
"values": [
"terms": [
"field": "tags.value.raw",
"min_doc_count": 1
]
]
]
]
]
]
]
]
]
]
]
]
But now i get the "Cannot assign to immutable expression of type "AnyObject?!"" error but i clearly used the "var" when creating the request? Does anyone know how to solve this? Is there any better way of creating such long Dictionaries/JSON files? Thanks

Resources