Universal Print via Microsoft Graph API - microsoft-graph-api

I have integrated universal printer in my App(outsystems) using Microsoft graph APIs, it's working as expected except pageRanges, for example I have document containing 5 pages and I want to print 3rd and 4th page only but it is printing all 5 pages every time.
Following is the JSON representation of the request
{
"configuration": {
"quality": "medium",
"dpi": 600,
"duplexMode": "oneSided",
"copies": 1,
"colorMode": "auto",
"mediaSize": "A4",
"collate": true,
"feedOrientation": "longEdgeFirst",
"fitPdfToPage": false,
"inputBin": "tray-1",
"orientation": "portrait",
"pageRanges": [
{
"start": 3,
"end": 4
}
],
"pagesPerSheet": 1,
"scaling": "none"
}
}

Related

Filtering chloropleth data using a slider for annual data in vega-lite

I have some geojson grids that map through to some annualised sales data over a period of 25 years. I am really struggling to filter this sales data by year to show the trends in a chloropleth map.
d3 = require('d3-dsv');
map_json = FileAttachment("Time_line#2.geojson").json()
sales_data = FileAttachment("Timeline_test#1.csv").csv()
vegalite = require('#observablehq/vega-lite')
vegalite ({
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"width": 600,
"height": 350,
"data": {
"name": "mapdata",
"values": map_json,
"format": {"property": "features"},
},
"params": [{
"name" : "AnnualPeriod",
"value": 1995,
"bind" : {"input": "range", "min":1995, "max":2020,"step":1 }
}],
"transform" : [{
"lookup": "properties.id",
"from": {
"data": { "values": sales_data,},
"format":"csv",
"key": "derived_boundary_id",
"fields": ["sales_volume"],
},
},],
"layer": [
{
"mark": "geoshape",
"encoding": {
"color": {
"field": "sales_volume",
"type": "quantitative",
"scale": {"scheme": "Oranges"},
},
"stroke": { "value": "#ff75"},
},
},
]
})
I have tried to add transform.filter and cannot get it to work. At the moment it appears to be taking the first sales_data record for each of the boundary_ids.
I would like the data to be filtered according to the setting of the AnnualPeriod slider.
I think I need to include something like
"transform" :[{"filter": "datum.year == AnnualPeriod"}]
I have tried it in the transform section, with the lookup between the sales_data and the geojosn objects.
I have also tried to filter in and around the geoshape mark but neither work.
Does anyone have any ideas?
The is a sample of the sales_data:
sales_volume,year,derived_boundary_id
5,2015,602212
2,2016,602212
2,2019,602212
5,1995,602213
7,1996,602213
6,1997,602213
7,1998,602213
9,1999,602213
10,2000,602213
7,2001,602213
5,2002,602213
5,2003,602213
9,2004,602213
5,2005,602213
...
where the last column maps to an "id" in the geojson data.
and this is the 'map' that I get. Always the same, irrespective of the slider setting.
I have eventually worked out how to get this to work.
Create the main data source as the sales data and attach the maps/geojson to this via a transform/lookup.
It seems so simple now, but I thought I would post the result so others can see how it can be achieved.
These observations may help others:
The transform can take the "year" filter as well as the map_json lookup.
The map/json lookup is referenced as "geo" to make it easier to understand
The geoshape mark then references, via the encoding, this geojson "geo" object.
Thanks to Mike Bostock and the Observable and Vega-Lite team for their excellent work.
vegalite ({
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"width": 600,
"height": 600,
"data": {
"values": sales_data,
},
"params": [{
"name" : "AnnualPeriod",
"value": 1995,
"bind" : {"input": "range", "min":1995, "max":2020,"step":1 }
}],
"transform" : [
{"filter" : "year(datum.year) === AnnualPeriod"},
{
"lookup": "derived_boundary_id",
"from" : {
"data": {
"values": map_json,
"format": {"property": "features"},
},
"key":"properties.id",
},
"as":"geo",
}
],
"mark":"geoshape",
"encoding": {
"shape": {
"field":"geo",
"type":"geojson",
},
"color":{
"field":"sales_volume",
"type":"quantitative",
"scale": {
"scheme":"Oranges",
"domain": [0,15],
},
}
}
})
How's your progress? I am not familiar with Choropleths, but by comparing with the Vega Examples, I spot 2 differences you may wanna take a look:
Choropleth needs a projection
Map data should be placed in lookup transform, and sale data in normal data. Ref 1 Ref 2
Do feel free to correct me if I am wrong. If you need more help, please share an editor with dummy data because I found it hard to make good use of the sale data you provided :'(

Unable to add Teams/SharePoint file attachment in a task to ' Tasks by Planner and To Do '

I have a fully built API, that creates tasks into MS Teams "Tasks by Planner and To Do".
MS actual graph API used POST https://graph.microsoft.com/v1.0/planner/tasks
Sample API:
{
"routeId": "7fcxxxxx-xxxx-xxxx-xxxx-5d35838xxxxx",
"userId": "77cxxxxx-xxxx-xxxx-xxxx-5f09858xxxxx",
"tenantId": "dcdxxxxx-xxxx-xxxx-xxxx-31002a1xxxxx",
"title": "Task: Add you task title",
"hospitalAssignment": null,
"percentComplete": 0,
"createdTimestamp": "2021-04-20T01:51:49Z",
"startDateTimestamp": "2021-04-20T18:10:15Z",
"dueDate": "2021-11-20T11:47:33.000Z",
"Notes": "Add some useful notes here",
"checklistItems": [
{
"title": "itema"
},
{
"title": "itemb"
}
],
"attachments": [
{
"url": "https://www.google.com",
"alias": "link"
},
{
"url": "https://teams.microsoft.com/file/....",
"alias": "Test Document 1"
},
{
"url": "https://random.sharepoint.com/sites/...",
"alias": "Test Document 2"
},
],
"comments": "null,",
"priority": null
}
Hitting the above API creates a task in the planner as seen below
So, here is an issue - when I try to click on link it took me to the browser and opens up google which is fine. Now, when I click on Test Document 1 or Test Document 2 it throws an unknown error and Sorry, something went wrong respectively.
After that, I created the task manually and adding the attachments from Add Attachment and paste the links to the file there, then click the files works and opens up the documents.
Assuming you are referring to adding / updating the Planner Task Details for a PlannerTask;
there is a sample provided of adding (PATCH) a pptx file using a 'teams path' as you referred to it.
Note that the path must be (url)encoded.
Tasks - plannerTaskDetail < references
https://learn.microsoft.com/en-us/graph/api/resources/plannerexternalreferences?view=graph-rest-1.0
{
"https%3A//contoso%2Esharepoint%2Ecom/teams/agile/documents/AnnualReport%2Epptx":
{
"#odata.type": "microsoft.graph.externalReference", // required in PATCH requests to edit the references on a task
"alias": "Agile Team Annual Report",
"lastModifiedBy": {
"user": {
"id": "ebf3b108-5234-4e22-b93d-656d7dae5874"
}
},
"lastModifiedDateTime": "2015-09-21T17:45:12.039Z",
"previewPriority": "0009005756397228702",
"type": "PowerPoint"
}
}

Create OnlineMeeting in MS Graph with Call-in Info

I am building some utilities to automate aspects of Microsoft Teams at my company. One thing we are trying is automating scheduling/creation of Online Meetings under various circumstances. Overall this is working fine, but I can't figure out how to get / attach telephone call-in information for the calls we're creating.
Here's an example POST /app/onlineMeetings:
{
"meetingType": "meetNow",
"participants": {
"organizer": {
"identity": {
"user": {
"id": "<user-id>"
}
}
}
},
"subject": "Personal Room"
}
And here's what a typical response looks like:
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#app/onlineMeetings/$entity",
"joinUrl": "<join-url>",
"subject": "Personal Room",
"isCancelled": false,
"meetingType": "MeetNow",
"accessLevel": "SameEnterprise",
"id": "<meeting-id>",
"audioConferencing": null,
"meetingInfo": null,
"participants": {
"organizer": {
"upn": "<user-name>",
"sipProxyAddress": "<user-name>",
"identity": {
}
},
"attendees": []
},
"chatInfo": {}
}
As you can see, the audioConferencing key is null. If a user accesses the joinUrl, they can join the call and audio conferencing information is displayed at that time -- but I can't figure out how to get it out in advance (e.g. to send in an email).
Also note that since this is not a VTC-enabled meeting, the id can't be used to issue a new GET request for additional information, as discussed here

How to share uploaded image in a channel?

I upload an image to slack using https://slack.com/api/files.upload
not specifying channels field in the request.
I can see the image in the web interface. What the api call should be to share the uploaded image in some channel at some point in the future?
I tried to upload an image and response from slack was:
{
"ok": true,
"file": {
"id": "FHJ9QTX1V",
"created": 1554115093,
"timestamp": 1554115093,
"name": "scaled_IMG-20190324-WA0002.jpg",
"title": "scaled IMG-20190324-WA0002",
"mimetype": "image/jpeg",
"filetype": "jpg",
"pretty_type": "JPEG",
"user": "UGRR6FCF7",
"editable": false,
"size": 217356,
"mode": "hosted",
"is_external": false,
"external_type": "",
"is_public": false,
"public_url_shared": false,
"display_as_bot": false,
"username": "",
"url_private": "https://files.slack.com/files-pri/TGQU3SCHF-FHJ9QTX1V/scaled_img-20190324-wa0002.jpg",
"url_private_download": "https://files.slack.com/files-pri/TGQU3SCHF-FHJ9QTX1V/download/scaled_img-20190324-wa0002.jpg",
"thumb_64": "https://files.slack.com/files-tmb/TGQU3SCHF-FHJ9QTX1V-fa34003fce/scaled_img-20190324-wa0002_64.jpg",
"thumb_80": "https://files.slack.com/files-tmb/TGQU3SCHF-FHJ9QTX1V-fa34003fce/scaled_img-20190324-wa0002_80.jpg",
"thumb_360": "https://files.slack.com/files-tmb/TGQU3SCHF-FHJ9QTX1V-fa34003fce/scaled_img-20190324-wa0002_360.jpg",
"thumb_360_w": 360,
"thumb_360_h": 270,
"thumb_480": "https://files.slack.com/files-tmb/TGQU3SCHF-FHJ9QTX1V-fa34003fce/scaled_img-20190324-wa0002_480.jpg",
"thumb_480_w": 480,
"thumb_480_h": 360,
"thumb_160": "https://files.slack.com/files-tmb/TGQU3SCHF-FHJ9QTX1V-fa34003fce/scaled_img-20190324-wa0002_160.jpg",
"thumb_720": "https://files.slack.com/files-tmb/TGQU3SCHF-FHJ9QTX1V-fa34003fce/scaled_img-20190324-wa0002_720.jpg",
"thumb_720_w": 720,
"thumb_720_h": 540,
"thumb_800": "https://files.slack.com/files-tmb/TGQU3SCHF-FHJ9QTX1V-fa34003fce/scaled_img-20190324-wa0002_800.jpg",
"thumb_800_w": 800,
"thumb_800_h": 600,
"thumb_960": "https://files.slack.com/files-tmb/TGQU3SCHF-FHJ9QTX1V-fa34003fce/scaled_img-20190324-wa0002_960.jpg",
"thumb_960_w": 960,
"thumb_960_h": 720,
"thumb_1024": "https://files.slack.com/files-tmb/TGQU3SCHF-FHJ9QTX1V-fa34003fce/scaled_img-20190324-wa0002_1024.jpg",
"thumb_1024_w": 1024,
"thumb_1024_h": 768,
"image_exif_rotation": 1,
"original_w": 1040,
"original_h": 780,
"permalink": "https://autolainen.slack.com/files/UGRR6FCF7/FHJ9QTX1V/scaled_img-20190324-wa0002.jpg",
"permalink_public": "https://slack-files.com/TGQU3SCHF-FHJ9QTX1V-3366c52c9c",
"comments_count": 0,
"is_starred": false,
"shares": {},
"channels": [],
"groups": [],
"ims": [],
"has_rich_preview": false
}
}
And then tried to share the image using /api/chat.postMessage:
{
"channel": "CH68ZSHFA",
"text": "test",
"blocks": [
{
"type": "section",
"text": {
"type": "plain_text",
"text": "test"
}
},
{
"type": "image",
"image_url": "https://autolainen.slack.com/files/UGRR6FCF7/FHJ9QTX1V/scaled_img-20190324-wa0002.jpg",
"alt_text": "attachment"
}
],
"as_user": false,
"username": "Client name"
}
I used url from url_private, url_private_download, permalink, permalink_public fields of the file description but got the same response:
{
"ok": false,
"error": "invalid_blocks",
"response_metadata": {
"messages": [
"[ERROR] downloading image failed [json-pointer:/1/image_url]"
]
}
}
Unfortunately there is no official API method to share a file on your workspace after it has been uppladed. So if you don't include the channel(s) in your initial files.upload request there is no official way to share that file later on.
But there is an unofficial API method called files.share, which has that very functionality. It works perfectly, but you will need a legacy token to use it, so this might not be a solution for you.
Another way to use an image on Slack is to include it in a message (as you are trying in your code example). Technically speaking that is not the same as sharing a file on Slack, since it only works for images and provide limited functionality for users.
It will work though, but only if your image URL is public, because chat.postMessage only works with public URLs to images and files on Slack are private by default (which means you need to provide authorization in any request to access that file from outside of Slack).
To get a public URL for your file you can call the API method files.sharedPublicURL after you uploaded it. You will get a public URL as response, which you can then use to include that image in your message.

Application Insights API $select not returning all results when values share part of path

I'm not sure if this is an OData issue or an Application Insights issue, but the App Insights API is not giving me all of the values I selected. It works normally most of the time, but when I ask for two values that share the beginning of their path, it only gives me the second value I asked for.
Here's an example of my issue:
data:
{
"count": 1,
"type": "customEvent",
"customDimensions": {
"success": "true",
"version": "ver-1"
},
"other": {
"key": "val-1"
}
},
{
"count": 2,
"type": "customEvent",
"customDimensions": {
"success": "false",
"version": "ver-2"
},
"other": {
"key": "val-2"
}
}
These all return the results that I'm expecting:
Query: $select=count,type
{
"count": 1,
"type": "customEvent"
},
{
"count": 2,
"type": "customEvent"
}
Query: select=customDimensions/success,other/key
{
"customDimensions": {
"success":"true"
},
"other": {
"key":"ver-1"
}
},
{
"customDimensions": {
"success":"false"
},
"other": {
"key":"ver-2"
}
}
However, if I try to get two values that start with the same path, it only shows me the second one.
Query: select=customDimensions/success,customDimensions/version
{
"customDimensions": {
"version":"ver-1"
}
},
{
"customDimensions": {
"version":"ver-2"
}
}
Is this an issue with either OData or Application Insights, or is there some other way I can format my query to give me the information I want? Thanks!
Update:
You can use the query api as following to fetch the data:
https://api.applicationinsights.io/v1/apps/Your_application_id/query?query=requests
| where timestamp >ago(5h)
| project customDimensions.UsersNamed, customDimensions.TenantsCoded
I test it in postman, see screenshot below:
Seems that your App Insights query is ok, I tested it using this .
I fetch the operation/name and operation/id(which starts with same path), original like this:
Then input some necessary condition, as screenshot below:
After click "Fetch" button, you can see the operation/name and operation/id are both returned.

Resources