JavaScript API is returning different characters for item ids than expected for certain characters

geetarman 26 Reputation points
2023-08-30T07:00:48.27+00:00

I am developing an outlook web addin that allows a user to select an email (or one of its attachments) and then send it to a service that uses Graph API to retrieve the email and analyse it. To do this I simply send the item id via a rest service. I am finding that if the id contains a '-' then the Javascript API actually replaces it with a '/' character and in that case this causes the Graph API to throw an error. I am having to specifically replace '/' characters with a '-' in order to get some to work but I don't consider this a long term solution (even though I understand that the '/' character may be invalid in an item id and never actually be present). I think that I have also seen that the '_' character seems to be replaced with a '+' character but this doesn't seem to be causing an issue.

Is there some special encoding that the Javascript API is using or this a bug in the javascript api?

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
1,001 questions
{count} votes

1 answer

Sort by: Most helpful
  1. geetarman 26 Reputation points
    2023-09-27T11:50:06.8033333+00:00

    found out what this is myself for anyone who comes across it. It turns out that the itemId for EWS and Rest services are slightly different. The itemId obtained from the API is in EWS format and must be converted to the REST format if you want to use in in a REST service (eg microsoft graph). The javascript API does contains methods to convert between the two formats.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.