Is there a way to post a message with a code snippet? - microsoft-graph-api

The new way to upload images as hosted content through the Send Message endpoint is great! However, is there a way to upload text/plain as hosted content in order to post a Code Snippet Card in a message?
I have tried uploading text but the response gives me an error that says that the only content types allowed are 'image/jpg,image/jpeg,image/png'.
Example request:
{
"body": {
"contentType": "html",
"content": "<attachment id=\"4d92eb51ab9c48ebb5b364794a2fa569\"></attachment>"
},
"attachments": [
{
"id": "4d92eb51ab9c48ebb5b364794a2fa569",
"contentType": "application/vnd.microsoft.card.codesnippet",
"contentUrl": null,
"content": "{\"name\":\"\",\"language\":\"CSharp\",\"lines\":1,\"wrap\":false,\"codeSnippetUrl\":\"../hostedContents/1/$value\"}",
"name": null,
"thumbnailUrl": null
}
],
"hostedContents":[
{
"#microsoft.graph.temporaryId": "1",
"contentBytes": "VGVzdA==",
"contentType": "text/plain"
}
]
}
Response:
{
"error": {
"code": "BadRequest",
"message": "Unsupported content type in hostedContent with Id '1'. Allowed values are 'image/jpg,image/jpeg,image/png'",
"innerError": {
"date": "2020-10-07T12:17:15",
"request-id": "ed24f5df-3e1f-4871-b430-e4c1c9f30348",
"client-request-id": "ed24f5df-3e1f-4871-b430-e4c1c9f30348"
}
}
}

I received an answer in the Documentation GitHub: https://github.com/microsoftgraph/microsoft-graph-docs/issues/10210#issuecomment-705050649
Code snippets are not supported at the moment. They are on list of things to support, but there is no timeline to share yet.

Related

Graph API search query error - Unexpected segment DynamicPathSegment. Expected property/$value

I am unable to search using microsoft graph api. The documentation is here.
Below is the sample provided in documentation, which itself is not working. Can someone suggest please. I actually want to search for people (and as per documentation /search is recommended way over /people. with /people query I am getting issue as faced in another thread)
URL : https://graph.microsoft.com/v1.0/users/<my mailbox name>/search/query
Request data:
{
"requests": [
{
"entityTypes": [
"message"
],
"query": {
"queryString": "contoso"
},
"from": 0,
"size": 25
}
]
}
Response:
{
"error": {
"code": "Request_BadRequest",
"message": "Unexpected segment DynamicPathSegment. Expected property/$value.",
"innerError": {
"date": "2023-01-18T16:19:05",
"request-id": "29a310fe-b5cf-4ea1-a995-3a09941d6d13",
"client-request-id": "29a310fe-b5cf-4ea1-a995-3a09941d6d13"
}
}
}
Send the POST request to https://graph.microsoft.com/beta/search/query endpoint.
POST https://graph.microsoft.com/beta/search/query
Request body
{
"requests": [
{
"entityTypes": [
"person"
],
"query": {
"queryString": "Sandeep"
},
"from": 0,
"size": 25
}
]
}
Searching for people requires delegated permissions.
Searching only works for searching the signed-in user's relevant people, not for searching people relevant to other users.

Create Workforce Integration using the graph API

I am using this endpoint in POSTMAN: Endpoint: https://graph.microsoft.com/v1.0/teamwork/workforceIntegrations
with requst body
Request body:
{
"apiVersion": 1,
"displayName": "samplename",
"encryption": {
"protocol": "sharedSecret",
"secret": "someescretvalueasper the doc"
},
"isActive": true,
"supportedEntities": "shift",
"url": "sampleurl.com"
}
I have followed all steps as mentioned in the documentation here https://learn.microsoft.com/en-us/graph/api/workforceintegration-post?view=graph-rest-1.0&tabs=http
however I am getting this error
{
"error": {
"code": "BadRequest",
"message": "{\"error\":{\"title\":\"Something went wrong\",\"externalErrorMessage\":\"Bad Request\",\"externalSource\":\"ShiftBookingsFlow\",\"externalImageLink\":null,\"externalData\":null,\"code\":\"BadRequest\",\"message\":\"Sorry your change couldn’t be completed.\",\"details\":[],\"innererror\":{\"code\":\"WorkforceIntegrationError\"}}}",
"innerError": {
"date": "2022-12-18T23:47:36",
"request-id": "d8e370a1-1d63-4137-9b49-07c74df6861b",
"client-request-id": "d8e370a1-1d63-4137-9b49-07c74df6861b"
}
}
}
Can anyone help me understand what I am doing wrong over here?
I expect a 200 Ok response but it is giving 400 bad request.
Is there any pre-requirsite to this API?

Unable to retrieve event details using Microsoft Graph API 1.0

Has anyone got Microsoft Graph API working for EventMessage? i.e reading email content of EventMessage using Graph API.
Looks like it has actionable card and graph API 1.0 is not able to read it.
Provided delegate access to user for a room resource.
On event creation for that room, mail is received by the delegated user in inbox. The mail type is eventMessage ("#odata.type": "#microsoft.graph.eventMessage").
On fetching the mail through GraphAPI v1.0, the event values are not visible in the response.
Also on setting the Expand property for the mail in graph API as per docs, results in below error.
{ "error": {
"code": "BadRequest",
"message": "Parsing Select and Expand failed.",
"innerError": {
"request-id": "310bbcce-bdd8-4cb6-890c-035243a5ab6d",
"date": "2020-01-21T09:18:10"
}
}
}
I'm unable to repro your issue. The Microsoft Graph API returns details for event messages. Can you provide repro steps, request/response capture, and the values that you'd expect to see?
I used v1.0/me/messagesto get all of the messages to find an eventMessage. I then perform the following to get details on the eventMessage:
GET https://graph.microsoft.com/v1.0/me/messages/{messagedId}
Response body:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('d09-94-498-a9777d4b')/messages/$entity",
"#odata.type": "#microsoft.graph.eventMessage",
"#odata.etag": "W/\"DAA2pU9s\"",
"id": "AAMkADEzOTExYjJkAAA=",
"createdDateTime": "2020-01-24T14:47:24Z",
"lastModifiedDateTime": "2020-01-24T21:08:07Z",
"changeKey": "DApU9s",
"categories": [],
"receivedDateTime": "2020-01-24T14:47:25Z",
"sentDateTime": "2020-01-24T14:47:11Z",
"hasAttachments": false,
"internetMessageId": "<AM5P3M#A38.EURPRD83.prod.outlook.com>",
"subject": "Accepted: Microsoft Graph DevX Roadmap",
"bodyPreview": "",
"importance": "normal",
"parentFolderId": "AAMk3AAA=",
"conversationId": "AAQkADEzOU4=",
"conversationIndex": "AdXReVPepTg==",
"isDeliveryReceiptRequested": null,
"isReadReceiptRequested": false,
"isRead": true,
"isDraft": false,
"webLink": "https://outlook.office365.com/owa/?ItemID=AAMkA%3D&exvsurl=1&viewmodel=ReadMessageItem",
"inferenceClassification": "focused",
"meetingMessageType": "meetingAccepted",
"body": {
"contentType": "text",
"content": ""
},
"sender": {
"emailAddress": {
"name": "Nicole",
"address": "sig#contoso.com"
}
},
"from": {
"emailAddress": {
"name": "Nicole",
"address": "sig#contoso.com"
}
},
"toRecipients": [
{
"emailAddress": {
"name": "Michael Mainer",
"address": "mm#contoso.com"
}
}
],
"ccRecipients": [],
"bccRecipients": [],
"replyTo": [],
"flag": {
"flagStatus": "notFlagged"
}
}

Unable to update OneNote page content

I send a PATCH request to https://graph.microsoft.com/beta/me/onenote/pages/1-3e7c1460680d4fe28501792ccda64915!119-304d54d6-d499-49f0-b231-cb3a9248e4e9/content
with body
[
{
"action": "replace",
"target": "p:{3e7c1460-680d-4fe2-8501-792ccda64915}{197}",
"content": "<p data-tag=\"to-do:completed\" style=\"margin-top:0pt;margin-bottom:0pt\">Sdasdsad</p>"
}
]
And I get response 500 with body:
{
"error": {
"code": "19999",
"message": "Something failed, the API cannot share any more information at the time of the request.",
"innerError": {
"request-id": "574a3b34-c354-4603-a73e-981984a56758",
"date": "2018-09-24T08:23:02"
}
}
}
The error is persistent. Does anybody knows where I can get help?

Unable to access Google Plus API in browser

i am working on to display wall posts (Stream) data using Google Plus API.
i have valid Client ID + API_KEY.
I am able to get response from Google Plus cloud console.i.e. by executing method I get Something like
Request
GET https://www.googleapis.com/plus/v1/people/myuserid/activities/public?maxResults=5&key={YOUR_API_KEY}
X-JavaScript-User-Agent: Google APIs Explorer
Response
200 OK
Show headers -
{
"kind": "plus#activityFeed",
"etag": "\"Mwea3qudNDf-hWWlPWi3n-YrU1Q/ovxXa0lmTRbwzkDa9o_iJ2pdFBs\"",
"nextPageToken": "CAIQgIi2z8bDugIgASgB",
"title": "Google+ List of Activities for Collection PUBLIC",
"updated": "2013-11-01T12:07:44.665Z",
"items": [
{
"kind": "plus#activity",
"etag": "\"Mwea3qudNDf-hWWlPWi3n-YrU1Q/JdSanh1QlMQ72Ubbabsiz2rP4B8\"",
"published": "2013-11-01T12:07:44.665Z",
"updated": "2013-11-01T12:07:44.665Z",
"id": "id",
"url": "https://plus.google.com/userid/posts/bYSPSVjXCXL",
"actor": {
"id": "116100754354787768146",
"displayName": "name",
"url": "https://plus.google.com/userid",
"image": {
"url": "someurl"
}
},
"verb": "post",
"object": {
"objectType": "note",
"content": "",
"url": "https://plus.google.com/userid/posts/bYSPSVjXCXL",
"replies": {
"totalItems": 1,
"selfLink": "https://content.googleapis.com/plus/v1/activities/z13xulwx3qjuxnkii04cjpsqgsjlyp2j23o/comments"
},
}
........
Seems good till now..but,when i use Request URL i.e https://www.googleapis.com/plus/v1/people/myuserid/activities/public?maxResults=5&key={MY_API_KEY} i got something from browser like this
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured"
}
],
"code": 403,
"message": "Access Not Configured"
}
}
where i am going wrong ?! how to get correct response from Browser. ? as i want to parse them and use these data in my Application.
NOTE: Google + API is ON.
Are you making sure that you have replaced {MY_API_KEY} with the API key that you have generated using the Cloud Console?
Are you using the Browser Key? It works OK for me.

Resources