SOLVED

POST /v1.0/teams/{id}/channels/{id}/messages returns Forbidden

%3CLINGO-SUB%20id%3D%22lingo-sub-1528138%22%20slang%3D%22ja-JP%22%3EPOST%20%2Fv1.0%2Fteams%2F%7Bid%7D%2Fchannels%2F%7Bid%7D%2Fmessages%20returns%20Forbidden%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1528138%22%20slang%3D%22ja-JP%22%3E%3CP%3EI'm%20trying%20to%20send%20message%20to%20teams%20channel.%3C%2FP%3E%3CP%3EThis%20is%20what%20Scope%20uses.%20%3CBR%20%2F%3E%20'''%20%3CBR%20%2F%3E%20User.Read.All%20%3CBR%20%2F%3E%20Group.ReadWrite.All%20%3CBR%20%2F%3E%20'''%3C%2FP%3E%3CP%3Ewhen%20I'm%20trying%20to%20call%20that%20API%20with%20the%20accurate%20token%2C%20I%20get%20this%20response%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%22error%22%3A%20%7B%0A%20%20%20%20%22code%22%3A%20%22Forbidden%22%2C%0A%20%20%20%20%22message%22%3A%20%22Forbidden%22%2C%0A%20%20%20%20%22innerError%22%3A%20%7B%0A%20%20%20%20%20%20%22date%22%3A%20%222020-07-17T02%3A01%3A44%22%2C%0A%20%20%20%20%20%20%22request-id%22%3A%20%2242c27cb9-7e10-4802-8ec5-19932d01a332%22%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20I%20need%20an%20Office%20365%20license%20to%20use%20it%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1528138%22%20slang%3D%22ja-JP%22%3E%3CLINGO-LABEL%3EGraph%20API%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1531186%22%20slang%3D%22en-US%22%3ERe%3A%20POST%20%2Fv1.0%2Fteams%2F%7Bid%7D%2Fchannels%2F%7Bid%7D%2Fmessages%20returns%20Forbidden%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1531186%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F710876%22%20target%3D%22_blank%22%3E%40Keita_Yama%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPresume%20you%20have%20checked%20that%20via%20Graph%20explorer%3F%20If%20so%20did%20you%20click%20on%20the%20new%20permissions%20tab%20to%20ensure%20everything%20that%20is%20required%20is%20consented%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%20I%20just%20want%20to%20be%20sure%20you%20are%20passing%20in%20a%20valid%20message%20payload%20too%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20for%20the%20licensing%20part%2C%26nbsp%3B%20I%20would%20say%20that%20ultimately%20if%20it%20is%20being%20posted%20as%20a%20user%2C%20that%20user%20would%20need%20to%20be%20licensed.%20However%20I%20would%20just%20try%20it%20vs%20a%20licensed%20user%20as%20is%20to%20confirm%20that%20theory.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHenry%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1532624%22%20slang%3D%22en-US%22%3ERe%3A%20POST%20%2Fv1.0%2Fteams%2F%7Bid%7D%2Fchannels%2F%7Bid%7D%2Fmessages%20returns%20Forbidden%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1532624%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F693840%22%20target%3D%22_blank%22%3E%40henryarphillips365%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%2C%20I%20tried%20it%20in%20Graph%20explorer.%3C%2FP%3E%3CP%3ETry%20it%20with%20an%20account%20without%20a%20Microsoft%20365%20Business%20Standard%20license%2C%20you%20will%20get%20an%20error.%3C%2FP%3E%3CP%3EThe%20parameter%20I%20am%20requesting%20is%20this.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%22body%22%3A%20%7B%0A%20%20%20%20%22content%22%3A%20%22Hello%20World%22%0A%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESending%20the%20same%20request%20from%20an%20account%20with%20an%20Office365%20license%20will%20be%20successful.%3C%2FP%3E%3CP%3EAre%20there%20APIs%20that%20are%20not%20available%20with%20or%20without%20a%20license%3F%20Tell%20me%20about%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1532626%22%20slang%3D%22en-US%22%3ERe%3A%20POST%20%2Fv1.0%2Fteams%2F%7Bid%7D%2Fchannels%2F%7Bid%7D%2Fmessages%20returns%20Forbidden%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1532626%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F710876%22%20target%3D%22_blank%22%3E%40Keita_Yama%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAh%2C%20OK.%20Sorry%2C%20so%20you%20have%20already%20proved%20the%20licensing%20point.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20afraid%20the%20Graph%20allows%20you%20to%20tap%20into%20the%20many%20O365%20services%2C%20but%20it%20does%20not%20circumvent%20permissions%20or%20licensing%20requirements.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20can%20only%20think%20if%20the%20message%20is%20to%20be%20posted%20as%20a%20non%20user%2C%20you%20would%20probably%20want%20it%20to%20be%20posted%20as%20a%20bot%20or%20something.%20That%20will%20still%20have%20its%20own%20requirements%20but%20may%20ring%20more%20true%20to%20your%20requirement%20of%20not%20wanting%20to%20post%20as%20a%20user.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20could%20also%20see%20if%20that%20call%20can%20be%20run%20with%20application%20permissions.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHenry%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I'm trying to send message to teams channel.

This is what Scope uses.
```
User.Read.All
Group.ReadWrite.All
```

when I'm trying to call that API with the acquired token, I get this response:

{
  "error": {
    "code": "Forbidden",
    "message": "Forbidden",
    "innerError": {
      "date": "2020-07-17T02:01:44",
      "request-id": "42c27cb9-7e10-4802-8ec5-19932d01a332"
    }
  }
}

 

Do I need an Office 365 license to use it? 

3 Replies

Hi @Keita_Yama 

 

Presume you have checked that via Graph explorer? If so did you click on the new permissions tab to ensure everything that is required is consented?

 

Also I just want to be sure you are passing in a valid message payload too?

 

As for the licensing part,  I would say that ultimately if it is being posted as a user, that user would need to be licensed. However I would just try it vs a licensed user as is to confirm that theory. 

 

Thanks

 

Henry

Hi@HenryPhillipsNimbitech 

 

Yes, I tried it in Graph explorer.

Try it with an account without a Microsoft 365 Business Standard license, you will get an error.

The parameter I am requesting is this.

{
  "body": {
    "content": "Hello World"
  }
}

 

Sending the same request from an account with an Office365 license will be successful.

Are there APIs that are not available with or without a license? Tell me about it.

 

best response confirmed by Keita_Yama (New Contributor)
Solution

@Keita_Yama 

 

Ah, OK. Sorry, so you have already proved the licensing point.

 

I am afraid the Graph allows you to tap into the many O365 services, but it does not circumvent permissions or licensing requirements.

 

I can only think if the message is to be posted as a non user, you would probably want it to be posted as a bot or something. That will still have its own requirements but may ring more true to your requirement of not wanting to post as a user.

 

You could also see if that call can be run with application permissions.

 

Thanks

 

Henry

www.000webhost.com