Getting 400 bad request from Microsoft Graph Api for SchemaExtensions - microsoft-graph-api

Limit of: 5 extension schema definitions can be written. !
Here is the response
{
"error": {
"code": "BadRequest",
"message": "Limit of: 5 extension schema definitions can be written.",
"innerError": {
"date": "2020-10-26T12:29:47",
"request-id": "requestID",
"client-request-id": "client-requestID"
}
}
}
And here is the request body
{
"id": "myMetaData",
"description": "My description",
"targetTypes": [
"Group"
],
"properties": [
{
"name": "shortName",
"type": "String"
},
{
"name": "supervisor",
"type": "String"
}
]
}
I have used delegated permision and used token generated by password since SchemaExtension needs delegated one and doesn't support application perm.

I got the answer , it was due to limit of the schemaExtensions that could be created other developer on the project already created 5 and since this was the limit set it showed this error

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.

Trying to create team with owner using principal name, gives error "Failed to find users with user principal name" but user is owner of 365 account

Request URL
https://graph.microsoft.com/v1.0/teams
Request Body
{
"template#odata.bind": "https://graph.microsoft.com/v1.0/teamsTemplates('standard')",
"displayName": "Team22",
"description": "My Sample Team’s Description",
"members": [
{
"#odata.type": "#microsoft.graph.aadUserConversationMember",
"roles": [
"owner"
],
"user#odata.bind": "https://graph.microsoft.com/v1.0/users('vishalkumar#4vswmg.onmicrosoft.com')"
}
]
}
Response Code 404
Response Preview
{
"error": {
"code": "NotFound",
"message": "Failed to find users with user principal name 'vishalkumar#4vswmg.onmicrosoft.com'",
"innerError": {
"date": "2022-05-13T06:55:15",
"request-id": "9df9a8fa-21cc-4455-b39f-ef1aca1d4b07",
"client-request-id": "24d55bd6-3f77-b808-221e-3f1a7af7dd5a"
}
}
}
The following payload worked for me:
Ref Doc: https://learn.microsoft.com/en-us/graph/api/team-post?view=graph-rest-1.0&tabs=http#example-9-application-permissions-using-user-principal-name
"template#odata.bind":"https://graph.microsoft.com/v1.0/teamsTemplates('standard')",
"displayName":"My Sample Team",
"description":"My Sample Team’s Description",
"members":[
{
"#odata.type":"#microsoft.graph.aadUserConversationMember",
"roles":[
"owner"
],
"user#odata.bind":"https://graph.microsoft.com/v1.0/users('jacob#contoso.com')"
}
]
}```
Keep in mind you can add only one owner at the time of Team creation using Graph API

Configuring activity types in a Microsoft teams app

I have sideloaded a teams app with an activity type, so that I could I could use the activity feed graph api. However, when I send a teams/<teamId>/sendActivityNotification request, I get 501 "Not Implemented". There are no specifics in the response.
{ "error": { "code": "NotImplemented", "message": "Failed to process request.", "innerError": { "date": "2021-04-16T07:48:31", "request-id": "bd92c3a5-9ec5-49a1-a2d5-057f7dd3c182", "client-request-id": "bd92c3a5-9ec5-49a1-a2d5-057f7dd3c182" } }}
I think I may be missing something about how graph API integrates with teams apps.
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.8/MicrosoftTeams.schema.json",
"manifestVersion": "1.8",
"id": "<APP_ID>",
"version": "1.0",
"packageName": "com.nikita",
"developer": {
"name": "Nikita Cool Dude",
"websiteUrl": "https://www.microsoft.com",
"privacyUrl": "https://www.microsoft.com",
"termsOfUseUrl": "https://www.microsoft.com"
},
"name": {
"full": "MMM service test",
"short": "MMM service test"
},
"accentColor": "#FFFFFF",
"description": {
"full": "Packages mmm activity types.",
"short": "Packages mmm activity types."
},
"icons": {
"outline": "mmm-small.png",
"color": "mmm-small.png"
},
"activities": {
"activityTypes": [
{
"type": "mmmChannelCreated",
"description": "New channel is created for an mmm event",
"templateText": "New <priority> <cfs> event"
}
]
},
"connectors": [
{
"connectorId": "<APP_ID>",
"scopes": ["team"]
}
]
}
Note that I am adding a connector I'm not using. Otherwise I get Error while reading manifest.json: "configurableTabs, staticTabs, bots, connectors, or composeExtensions" is required error when sideloading the app. The app id is created through portal.azure.com.
Below is the request payload, in case that is relevant. I based it very closely on examples in the graph API documentation.
{
"topic": {
"source": "entityUrl",
"value": "https://graph.microsoft.com/v1.0/teams/<teamId>/channels/<channelId>",
},
"activityType": "mmmChannelCreated",
"previewText": {
"content": "New important event!"
},
"templateParameters": [
{
"name": "priority",
"value": "P1"
},
{
"name": "cfs",
"value": "Armed Robbery"
}
]
}
Any ideas are appreciated!
In your manifest webApplicationInfo section is missing. The Teams app manifest must have the Azure AD app ID added to the webApplicationInfo section. Follow the requirements provided in documetation to use sendActivityNotification.

Is there a way to post a message with a code snippet?

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.

$count=true support in OneDrive API?

It looks like the OData $count parameter is not (yet?) supported in the Microsoft Graph API v1.0 for OneDrive.
Request URL: https://graph.microsoft.com/v1.0/me/drive/root/children?$count=true
Response:
{
"error": {
"code": "",
"message": "The query specified in the URI is not valid. Query option 'Count' is not allowed. To allow it, set the 'AllowedQueryOptions' property on EnableQueryAttribute or QueryValidationSettings.",
"innerError": {
"request-id": "e65aff74-1c6f-434b-8cd3-04e0c247fb71",
"date": "2016-10-19T09:48:39"
}
}
}
Is this understanding correct?
The $count parameter isn't supported with OneDrive. You can get a count of the children however by moving one level up:
/v1.0/me/drive/root/
This includes a folder property that contains the number of child items:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('id')/drive/root/$entity",
"createdDateTime": "2012-08-03T08:12:58Z",
"id": "{id}",
"lastModifiedDateTime": "2016-10-18T14:19:21Z",
"name": "root",
"webUrl": "{webUrl}",
"folder": {
"childCount": 28
},
"root": {},
"size": 0,
"specialFolder": {
"name": "documents"
}
}

Resources