A post call to add a new openTypeExtension to event data fails with “Resource not found for the segment 'extensions'” - microsoft-graph-api

I am trying to add an extension to the event resource using Graph Explorer. I am using POST on https://graph.microsoft.com/v1.0/event/extensions with request body
{
"#odata.type": "microsoft.graph.openTypeExtension",
"extensionName": "com.wrike.WrikeIDs",
"id": "",
"permalink": ""
}
I get the error
"Resource not found for the segment 'event'"
and sometimes I get
"The OData request is not supported"
Content type is application/json

The error message might be misleading.
Try to adjust the path to
POST https://graph.microsoft.com/v1.0/me/events/{event_id}/extensions

Related

Unable to get teams message attachment content using graph API

I am able to get message attachment information as shown below but unable to download the file content which is stored in share point site.
"attachments": [
{
"id": "fc323b65-2cee-48d9-9574-0e26eb74e9bb",
"contentType": "reference",
"contentUrl": "https://otdeveloper.sharepoint.com/sites/Test/Shared Documents/General/1Ex.txt",
"content": null,
"name": "1Ex.txt",
"thumbnailUrl": null
}
]
I am using the following get call for the above request with auth token
GET https://graph.microsoft.com/beta/groups/{{TeamId}}/drive/root:/Test/Shared Documents/General/1Ex.txt:/content
I tried the solution posted in
https://github.com/microsoftgraph/msgraph-sdk-javascript/issues/200
but I am getting 404 response.
Could you please check Get message API.You will receive the the attachments info in the response as shown below

Getting error "invalidRequest" when creating upload session (Microsoft Graph Api)

I am getting the below error when creating upload session (Microsoft Graph Api).
{
"error": {
"code": "invalidRequest",
"message": "Invalid request",
"innerError": {
"request-id": "6e9cc58e-d3b9-456e-a794-90486969296e",
"date": "2020-04-06T20:53:18"
}
}
}
Post request https://graph.microsoft.com/v1.0/me/drive/root:/testapi:/createUploadSession
Request body :
I have modified the request as below to make it work. See below :
POST https://graph.microsoft.com/v1.0/me/drive/items/01WCLVX5B7JBMYFMQKWNA3NVFODWCDUPGB:/3.pdf:/createUploadSession
I was implementing C# from here where the code was
var uploadSession = await graphClient.Me.Drive.Root
.ItemWithPath(itemPath)
.CreateUploadSession(uploadProps)
.Request()
.PostAsync();
In my case, I was able to fix it by updating itemPath by adding the full path to the file. For instance, if the path is
/RootFolder/Folder1
just update with file name like this
/RootFolder/Folder1/MyFile.pdf

Unsupported Media Type - 415 error in POST request in Graph Explorer

I am trying out Graph Explorer. I am able to get my profile from https://graph.microsoft.com/v1.0/me/.
But when I try to create a device using the Graph Explorer, it is returning Unsupported Media Type - 415 response.
My request and response are:
Request
POST https://graph.microsoft.com/v1.0/devices
Request headers
Content-type: application/json
Request body
{
"accountEnabled": false,
"alternativeSecurityIds": [
{
"type": 3,
"key": "base64Y3YxN2E1MWFlYw=="
}
],
"deviceId": "4c299165-6e8f-4b45-a5ba-c5d250a707ff",
"displayName": "Test device",
"operatingSystem": "linux",
"operatingSystemVersion": "1"
}
I have given the consent for all permissions under Modify permissions section.
Response
Unsupported Media Type - 415 - 1168ms
{
"error": {
"code": "Request_BadRequest",
"message": "The specified content type 'application/json;odata=minimalmetadata, application/json' contains either no media type or more than one media type, which is not allowed. You must specify exactly one media type as the content type.",
"innerError": {
"request-id": "11235ffc-1fb3-4324-a832-2c92274e98bf",
"date": "2020-04-06T16:55:17"
}
}
}
Edit
value of deviceId in the request data
"DeviceId" AND "Key" that you are passing in Request body should be Unique identifier. Change you sample Device-Id & Key and try again. It worked for me. and you also increased the length of device id by appending 1 at end.
Documentation for accountEnabled here.

Microsoft Graph-Delete planner task-Resource not found for the segment (ETag)?

I am trying to delete Planner task using Microsoft graph according to instruction on https://learn.microsoft.com/en-us/graph/api/plannertask-delete?view=graph-rest-1.0&tabs=http
GET works, DELETE does not.
Request should look like:
DELETE https://graph.microsoft.com/v1.0/planner/tasks/{id}
If-Match: W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc="
In my case, it is:
DELETE https://graph.microsoft.com/v1.0/planner/tasks/nWf2j63qnk69r69ZdK7135cAMVlSIf-Match:W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc="
What am I doing wrong?
GET
https://graph.microsoft.com/v1.0/planner/tasks/nWf2j63qnk69r69ZdK7135cAMVlS
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#planner/tasks/$entity",
"#odata.etag": "W/\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc=\"",
...
"id": "nWf2j63qnk69r69ZdK7135cAMVlS",
...
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment '\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc=\"'.",
"innerError": {
"request-id": "58d3c417-6474-422c-912d-e6fdaae856c3",
"date": "2019-09-06T23:47:35"
}
}
}
It appears you are trying to pass If-Match via request url:
DELETE https://graph.microsoft.com/v1.0/planner/tasks/nWf2j63qnk69r69ZdK7135cAMVlSIf-Match:W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc="
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
while it is expected to be provided via request headers, like this:
DELETE https://graph.microsoft.com/v1.0/planner/tasks/{id}
Headers:
If-Match: W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc="
Authorization: Bearer <access-token>
Graph Explorer example

Create a draft reply message give an error on providing payload

I am hitting the Outlook Office 365 API through Postman. I tried to create a draft reply message using this URL:
POST https://outlook.office.com/api/v2.0/me/messages/{message_id}/createreply
The body contained:
body: {
"Comment": "Sounds great! See you tomorrow."
}
but I got the following error:
{
"error": {
"code": "RequestBodyRead",
"message": "The parameter 'Comment' in the request payload is not a valid parameter for the operation 'CreateReply'."
}
}
I have used this call based on the documentation.
This issue also exists for create a draft reply all message and create a draft forward message.
This is because you're placing comment within the body, it should stand on it's own. From this documentation:
POST https://outlook.office.com/api/beta/me/messages/AAMkADA1MTAAAAqldOAAA=/createreply
Content-Type: application/json
{
"Comment": "Fanny, Randi, would you name the group if the project is approved, please?"
}
Note that it is {"comment": "string"} and not body:{"comment": "string"}.

Resources