Kevin Koenig
Kevin Koenig

Reputation: 25

issue with Microsoft graph api with forward slashes "/" in /me/events/{id}

I am having a similar issue to the post described here.

How to get an event ID from the HitID returned by a Microsoft Graph search query?

In my case I am not trying to do a patch, but just a lookup via the v1.0/me/events/{id} get request. I am using the search API of Microsoft graph API. It returns me a HitId with forward slashes in it. I tried to resolve it in the exact same way as the post describes, but cant seem to get it to work. My id parameter is:

AAMkADgwZjlhNmJjLWNiMGQtNGE5MS1hMDVkLTNkNTU2ZWE5ZmM5ZgBGAAAAAAAjq0f6CrWJSoJ6oKcYbrJfBwAyr2CWzX9CSrX7fgfr1AFOAAAAAAENAAAyr2CWzX9CSrX7fgfr1AFOAAV/rENQAAA=

I replaced the / with %252F and the call still fails. The new request id is:

AAMkADgwZjlhNmJjLWNiMGQtNGE5MS1hMDVkLTNkNTU2ZWE5ZmM5ZgBGAAAAAAAjq0f6CrWJSoJ6oKcYbrJfBwAyr2CWzX9CSrX7fgfr1AFOAAAAAAENAAAyr2CWzX9CSrX7fgfr1AFOAAV%252FrENQAAA=

which still fails in exactly the same way. To isolate the problem I used Microsoft Graph API explorer to test the request, which returns the following error message

{
    "error": {
        "code": "RequestBroker--ParseUri",
        "message": "Resource not found for the segment 'rENQAAA='.",
        "innerError": {
            "date": "2021-03-18T07:48:24",
            "request-id": "83cecc8b-f510-4cf0-b5f1-e4cd5f09e223",
            "client-request-id": "530677e9-fa2d-a842-149e-a8db4939f3b8"
        }
    }
}

I cant seem to find any suitable documentation on how to resolve the issue.

Thanks in advance for any help.

Upvotes: 0

Views: 619

Answers (2)

vishal_the_prince
vishal_the_prince

Reputation: 1

You need to replace the "/" in your message id with "-"

const outlookRestUrl = Office.context.mailbox.restUrl + '/v2.0/me/messages/' + itemId.replaceAll("/","-") + '/$value';

Upvotes: -2

Shiva Keshav Varma
Shiva Keshav Varma

Reputation: 3575

Where ever you get / simply replace it with -. This will resolve your issue.

Upvotes: 5

Related Questions