0
votes

I am integrating ServiceNow with Teams specifically to push notifications to users and channels using microsoft graph api.

Issue #1 -

I have configured an OAuth profile for azure app to utilize microsoft graph API, setup required API permissions and calling various chat related API functions. For 'Create Chat' request I am getting below error:

    responseBody: {    
        "error": {
        **"code": "UnknownError",**
        "message": "",
        "innerError": {
        "date": "2021-01-29T09:20:53",
        "request-id": "90a99bf5-048f-445b-b58c-ee46fc30edf3",
        "client-request-id": "90a99bf5-048f-445b-b58c-ee46fc30edf3"
        }
      }
    }

API call -

      var restMessage = new sn_ws.RESTMessageV2();
        restMessage.setHttpMethod("POST");
        restMessage.setEndpoint("https://graph.microsoft.com/beta/chats");
        restMessage.setRequestHeader('Content-Type', 'application/json');
        restMessage.setRequestHeader('Authorization', 'Bearer ' + retrieveToken()); //retrieveToken() function creates access token.
        restMessage.setAuthenticationProfile('oauth', 'a5325df007022010f60df7fc7c1ed0a2');
        restMessage.setRequestBody(global.JSON.stringify(
        
            {"chatType": "oneOnOne","members": 
              [
                {
                    "@odata.type": "#microsoft.graph.aadUserConversationMember",
                    "roles": ["owner"],
                    "[email protected]": "https://graph.microsoft.com/beta/users('<userID>')"
                },
                {
                    "@odata.type": "#microsoft.graph.aadUserConversationMember",
                    "roles": ["owner"],
                    "[email protected]": "https://graph.microsoft.com/beta/users('<userID>')"
                }
              ]
            }
        
        ));

var response = restMessage.executeAsync();
var responseBody = response.getBody();
gs.info('responseBody: '+responseBody);

Most of the suggestions are to set appropriate API permissions. This is already set correctly on Azure (both delegated and apppication permissions) and in OAuth entity scope in servicenow.

Issue #2 -

For the same setup instead of usign scripted API, I defined REST Message record and trying to get the token by clicking 'Get OAuth Token' related link and getting following error:

https://dev72030.service-now.com/oauth_redirect.do?error=invalid_client&error_description=AADSTS650053%3a+The+application+%27msgraph-client-app%27+asked+for+scope+%27**Chat.Read.All%27+that+doesn%27t+exist+on+the+resource**+%2700000003-0000-0000-c000-000000000000%27.+Contact+the+app+vendor.%0d%0aTrace+ID%3a+b0b9ff39-fd1a-49c9-85fa-3c8c71943600%0d%0aCorrelation+ID%3a+9c276922-3a77-4cc1-890b-23177ffd1845%0d%0aTimestamp%3a+2021-01-29+10%3a31%3a27Z&state=-1877865371#

This say I need to set 'Chat.Read.All' API permission. This is already provided on both sides, Azure app and OAUth profile in SNOW.

What am I missing

1
Ask questions one in a question - it will help the community members to help.Dev
We are not able to repro the issue at our end. Could you please check this docs? For second issue: Could you please check the permissions on src by going through the jwt.ioNikitha-MSFT

1 Answers

0
votes

Could you please check this docs? For second issue: Could you please check the permissions on src by going through the jwt.io