ErrorInvalidIdMalformed while accessing message through Microsoft Graph API - microsoft-graph-api

I am trying to access message using graph API with the following URL.
_graphAPIEndpoint = Uri.EscapeUriString("https://graph.microsoft.com/v1.0/me/messages/8577e5c2-3d1b-4882-b930-02de5ad18809#CH1GMEHUB07.gme.gbl");
However, I keep getting the following response:
{
"error": {
"code": "ErrorInvalidIdMalformed",
"message": "Id is malformed.",
"innerError": {
"request-id": "8b2d8f88-ff5b-44f7-bb71-8867a03136b7",
"date": "2018-06-07T18:00:32"
}
}
}
Any suggestions on what's wrong?

My bad. Message ID value should be taken from id field passed by Graph API. To use message ID, following query works:
_graphAPIEndpoint = "https://graph.microsoft.com/v1.0/me/messages?$filter=internetMessageId eq ''"

Related

How to Filter Query Results from Microsoft-Graph-People?

I am trying to make a Get Request to the Microsoft Graph API for a specific user's email within my organization. Therefore, I have created the following query, to return the displayName, scoredEmailAddresses, and userPrincipalName for user "jane doe", whose userPrincipalName endsWith #something.com (see below). However, when I run this query in Graph Explorer, I receive the error below. Can any advise how I can fix this query?
QUERY:
https://graph.microsoft.com/v1.0/me/people?$search="Jane
Doe"&$select=displayName,scoredEmailAddresses,userPrincipalName&$count=true&$filter=endsWith(userPrincipalName,
'#something.com')
ERROR:
{
"error": {
"code": "ErrorInvalidUrlQueryFilter",
"message": "The query filter contains one or more invalid nodes.",
"innerError": {
"date": "2022-07-26T14:16:45",
}
}
}
It looks like that userPrincipalName does not support filtering.
If I try the simple filter query
https://graph.microsoft.com/v1.0/me/people?$filter=userPrincipalName eq 'john.doe#something.com'
The response returns an error
{
"error": {
"code": "ErrorInvalidProperty",
"message": "The property 'UserPrincipalName' does not support filtering.",
"innerError": {
"date": "2022-07-27T09:45:45",
"request-id": "9500af61-d1a9-4c9b-b405-05f9c07c81f1",
"client-request-id": "a0bda440-4f9b-aa4a-5d6c-4a0271bda023"
}
}
}
If you can directly search the user by following below API , why you are

The method openShiftsRequests return Resource not found for the segment 'openShiftsRequests'

Im try to get the pending shifts to approve in teams with api.
Pending shifts teams
Reading the API i think the correct method is https://learn.microsoft.com/en-us/graph/api/openshiftchangerequest-list?view=graph-rest-1.0
When I try to get this method using the graph explore the response request is :
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'openShiftsRequests'.",
"innerError": {
"date": "2020-09-04T17:33:34",
"request-id": "52f61a88-7f43-4653-9162-c8e90fc5998f"
}
}
}
My request is https://graph.microsoft.com/v1.0/teams/MY_TEAM_ID_WITH_SHIFT/schedule/openShiftsRequests
What can I do wrong??

Sort Events by Start Date

I need to be able to get the events in both directions ASC/DESC using Microsoft Graph API. I'm trying the following API to achieve that:
https://graph.microsoft.com/v1.0/me/events?$orderby=start
However, when I perform the request I get the following error:
{
"error": {
"code": "BadRequest",
"message": "The $orderby expression must evaluate to a single value of primitive type.",
"innerError": {
"request-id": "c00d676d-ef8e-418b-8561-80e08729da71",
"date": "2017-11-16T13:31:59"
}
}
}
Also, I tried to access the date directly:
https://graph.microsoft.com/v1.0/me/events?$orderby=start.dateTime
Got the following error:
{
"error": {
"code": "BadRequest",
"message": "The child type 'start.dateTime' in a cast was not an entity type. Casts can only be performed on entity types.",
"innerError": {
"request-id": "240342f5-d7f6-430b-9bd0-190dc3e1f73b",
"date": "2017-11-16T13:32:39"
}
}
}
Is there a way to sort events by date in ASC/DESC order?
You're very close but you're referencing DateTime incorrectly. The proper format is {parent}/{child}. These will work:
https://graph.microsoft.com/v1.0/me/events?$orderby=start/dateTime
https://graph.microsoft.com/v1.0/me/events?$orderby=start/dateTime desc

CreateNotBook via RESTapi for MSonenote 365

While creating Notebook in MS365 authorized account via REST api call .I am facing some issue ,could anyone let me know what changes I have to make for this.
Request:
POST - https://graph.microsoft.com:443/v1.0/me/notes/notebooks
Body : {
"name": "MSOneNoteBusiness_OSSA_5LyC"
}
Response
Body : {
"error": {
"code": "BadRequest",
"message": "Unsupported segment type. ODataQuery: users/8dc0a74f-0aa6-45f4-813b-92e910f40bd4/notes/notebooks",
"innerError": {
"request-id": "fa409682-5395-4189-a43c-757adcfaea35",
"date": "2017-06-28T10:08:06"
}
}
The request should be POST https://graph.microsoft.com/v1.0/me/onenote/notebooks, not /me/notes, and the request body should have the property displayName. We also have a sample for this in the Graph Explorer:

Failing to expand extensions on only one account

Trying to run just a basic https://graph.microsoft.com/v1.0/me?$expand=extensions
But either get this error
Expected ',' instead of '{'
with
{"#odata.context":"https://graph.microsoft.com/v1.0/$metadata#users/$entity"{
"error": {
"code": "BadRequest",
"message": "The entity instance value of type 'microsoft.graph.user' doesn't have a value for property 'id'. To compute an entity's metadata, its key and concurrency-token property values must be provided.",
"innerError": {
"request-id": "39759fbe-06ed-4176-8cc3-efe167a532cb",
"date": "2017-05-17T22:47:35"
}
}
}
I am trying to find the id of my openExtensions my account so I can delete some to make room because I must of accidentally added too many but I can't even get a list of the extensions and I can't even filter it by id. All works fine with other accounts I think i must have just bricked my account while playing around with it. Any ideas?
EDIT
Trying the query https://graph.microsoft.com/v1.0/me?$select=id,displayName&$expand=extensions
results in
{"#odata.context":"https://graph.microsoft.com/v1.0/$metadata#users(id,displayName,extensions)/$entity","id":"MY ID","displayName":"MY NAME","extensions#odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('MY ID')/extensions","extensions":[{"#odata.type":"#microsoft.graph.openTypeExtension"{
"error": {
"code": "InternalServerError",
"message": "Unsupported extension property type.",
"innerError": {
"request-id": "9fe3c7aa-f3d8-48be-90e4-b440516f9010",
"date": "2017-05-17T23:14:46"
}
}
}
I think I just ran into a similar problem.
I created my extension like this
var ext = new OpenTypeExtension();
ext.ExtensionName = "[Unique Name]";
ext.AdditionalData = new Dictionary<string, object>();
ext.AdditionalData.Add("[settingName]", "[settingValue]");
await graph.Me.Extensions.Request().AddAsync(ext);
But now I can no longer expand the extensions property for my account.
var profile = await graph.Me
.Request()
.Expand("extensions")
.GetAsync();
This throws a Microsoft.Graph.ServiceException:
Code: generalException
Message: Unexpected exception returned from the service.
When I try to make the request in the graph explorer, I get the following response,
{
"#odata.context":"https://graph.microsoft.com/v1.0/$metadata#users/$entity"
{
"error": {
"code": "BadRequest",
"message": "The entity instance value of type 'microsoft.graph.user' doesn't have a value for property 'id'. To compute an entity's metadata, its key and concurrency-token property values must be provided.",
"innerError": {
"request-id": "5e3887db-1687-461a-8d5c-da0f34eea83b",
"date": "2018-06-01T01:41:12"
}
}
}
}
So one of our devs took a look at the data and it looks like you were calling the API incorrectly - which was valid JSON, but not what our service can handle - especially on read back.
It looks like when you were creating an open extension, you were pushing the following in the payload:
{ "openTypeExtension": {
"#odata.type": "#Microsoft.Graph.Extensibility.openTypeExtension",
"extensionName": "roaming.settings",
"randvalue": 1
} }
But the openTypeExtension bit is not required and throws us off on a read back. What you should be sending is:
{
"#odata.type": "#Microsoft.Graph.Extensibility.openTypeExtension",
"extensionName": "roaming.settings",
"randvalue": 1
}
We've implemented a fix to prevent this in the future, which will roll out next week.
We have the IDs for your extensions, so you could delete them, but we're not sure how to communicate these to you securely. If you are OK with us providing them on this thread, please let us know.
Hope this helps,
I got the same error. I use Graph API lib.
Finally I was able to retrieve the extension other way - using Users.Extensions property (I guess it can be done against current user analogically - Me.Extensions).
I added the extension this way:
var additionalData = new Dictionary<string, object> { { "DataName", value } };
await graph.Users["userId"]
.Extensions
.Request()
.AddAsync(new OpenTypeExtension { ExtensionName = "uniqueExtensionName", AdditionalData = additionalData });
..and retrieving:
var extensionObject = ( await graph.Users["userId"].Extensions.Request().GetAsync() )
.CurrentPage[0];

Resources