Home

Chat thread creation API issues

%3CLINGO-SUB%20id%3D%22lingo-sub-302388%22%20slang%3D%22en-US%22%3EChat%20thread%20creation%20API%20issues%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-302388%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20trying%20to%20use%20the%26nbsp%3BPOST%20%2Fteams%2F%7Bid%7D%2Fchannels%2F%7Bid%7D%2FchatThreads%20API%20endpoint%20to%20post%20messages%2C%20however%20I'm%20experiencing%20the%20below%20problems.%20Does%20anybody%20have%20an%20idea%20what%20I%20may%20be%20doing%20wrong%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3EAttaching%20files%20doesn't%20seem%20to%20work.%20In%20the%20request%20I%20properly%20supply%20the%26nbsp%3BContentType%20and%20ContentUrl%20but%20no%20attachment%20shows%20up%20under%20the%20messages.%20I%20tried%20multiple%20data%20URL%20formats%20too%20(%22data%3A%5Bcontent%20type%5D%2C%3CBASE%2064%3D%22%22%20data%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2F%22%20%2F%3E%22%2C%20%22data%3A%3CSPAN%3E%3CBASE%2064%3D%22%22%20data%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2F%22%20%2F%3E%22%2C%26nbsp%3B%22data%3A%5Bcontent%20type%5D%3Bbase64%2C%3CBASE%2064%3D%22%22%20data%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2F%22%20%2F%3E%22)%2C%20but%20using%20the%20last%20one.%20It%20works%20if%20I%20try%20it%20in%20a%20browser%20so%20I'm%20confused%20(though%20these%20are%20bigger%20images%2C%20like%20around%208MB).%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3EI'm%20sometimes%20getting%20%22413%20(Request%20Entity%20Too%20Large)%22%20errors%20when%20trying%20to%20attach%20files.%20How%20big%20can%20files%20attached%20via%20the%20API%20be%2C%20or%20rather%2C%20how%20large%20can%20the%20whole%20request%20be%3F%20I%20don't%20think%20it's%20a%20limitation%20with%20file%20upload%20size%2C%20because%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FMicrosoft-Teams%2FFile-Size-Limitations-and-Total-volume%2Ftd-p%2F34006%22%20target%3D%22_self%22%3EGB-sized%20files%20can%20be%20attached%3C%2FA%3E%20from%20within%20Teams.%20A%2011.5MB%20request%20seems%20to%20blow%20it%20up.%3C%2FLI%3E%3CLI%3EThe%20timestamp%20doesn't%20seem%20to%20take%20effect%3A%20the%20timestamp%20shown%20in%20the%20chat%20will%20always%20be%20when%20the%20message's%20request%20was%20sent%2C%20not%20the%20older%20timestamp%20sent%20with%20the%20request.%20However%20the%20format%20I'm%20using%20is%20the%20same%20the%20API%20returns%20for%20existing%20messages.%3C%2FLI%3E%3C%2FOL%3E%3CP%3EThis%20sample%20below%20request%20demonstrates%20what%20I%20try%20with%20the%20timestamp%20and%20attachments%20(but%20here%20with%20an%20HTTPS%2C%20not%20data%20URL).%20The%20message%20gets%20created%20but%20with%20the%20mentioned%20defects.%3C%2FP%3E%3CPRE%3E%7B%20%3CBR%20%2F%3E%20%22rootMessage%22%3A%7B%20%3CBR%20%2F%3E%20%22createdDateTime%22%3A%222017-10-20T17%3A14%3A52.000Z%22%2C%3CBR%20%2F%3E%20%22body%22%3A%7B%20%3CBR%20%2F%3E%20%22contentType%22%3A%220%22%2C%3CBR%20%2F%3E%20%22content%22%3A%22Some%20message.%22%3CBR%20%2F%3E%20%7D%2C%3CBR%20%2F%3E%20%22attachments%22%3A%5B%20%3CBR%20%2F%3E%20%7B%20%3CBR%20%2F%3E%20%22contentType%22%3A%22image%2Fpng%22%2C%3CBR%20%2F%3E%20%22contentUrl%22%3A%22https%3A%2F%2Furl-to-image%22%2C%3CBR%20%2F%3E%20%22name%22%3Anull%2C%3CBR%20%2F%3E%20%22thumbnailUrl%22%3Anull%3CBR%20%2F%3E%20%7D%3CBR%20%2F%3E%20%5D%3CBR%20%2F%3E%20%7D%3CBR%20%2F%3E%7D%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERelated%2C%20but%20without%20answers%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FMicrosoft-Teams%2FGraph-API-Issues-while-creating-new-chat-thread%2Fm-p%2F242558%23M17353%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FMicrosoft-Teams%2FGraph-API-Issues-while-creating-new-chat-thread%2Fm-p%2F242558%23M17353%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20in%20advance!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-302388%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBots%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EChat%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-353541%22%20slang%3D%22en-US%22%3ERe%3A%20Chat%20thread%20creation%20API%20issues%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-353541%22%20slang%3D%22en-US%22%3E%3CP%3EI've%20never%20got%20it%20working%20and%20as%20you%20can%20see%20from%20the%20above%20posts%2C%20it%20seems%20this%20isn't%20possible.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-353530%22%20slang%3D%22en-US%22%3ERe%3A%20Chat%20thread%20creation%20API%20issues%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-353530%22%20slang%3D%22en-US%22%3E%3CP%3Ecan%20you%20give%20a%20example%20on%20json%26nbsp%3Bpayload%20for%20posting%20message%20with%20attachments%20for%20content%20type%20as%20file.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-321107%22%20slang%3D%22en-US%22%3ERe%3A%20Chat%20thread%20creation%20API%20issues%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-321107%22%20slang%3D%22en-US%22%3E%3CP%3ENobody%20with%20any%20ideas%3F%20The%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FMicrosoft-Teams%2FGraph-API-Issues-while-creating-new-chat-thread%2Fm-p%2F242558%22%20target%3D%22_self%22%3Elinked%20thread%3C%2FA%3E%20confirms%20that%20attachments%20are%20not%20supported%20yet%2C%20but%20what%20about%20the%20others%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-302494%22%20slang%3D%22en-US%22%3ERe%3A%20Chat%20thread%20creation%20API%20issues%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-302494%22%20slang%3D%22en-US%22%3E%3CP%3E4.%20I%20have%20a%20similar%20issue%20with%20creating%20threads%20in%20a%20name%20of%20a%20given%20user.%20I%20supply%20the%20user%20object%20with%20the%20correct%20ID%20but%20still%20the%20thread%20and%20message%20is%20created%20in%20the%20name%20of%20the%20user%20invoking%20the%20API%20request.%20The%20user%20supplied%20for%20the%20message%20doesn't%20%22stick%22.%3C%2FP%3E%3CP%3E5.%20Is%20it%20possible%20that%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fjson-batching%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ebatching%3C%2FA%3E%20doesn't%20work%20for%20this%20endpoint%3F%20I%20get%20%22Resource%20not%20found%20for%20the%20segment%20'beta'.%22%20for%20firing%20such%20request%20in%20a%20batch%2C%20see%20below.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%7B%20%3CBR%20%2F%3E%20%22requests%22%3A%5B%20%3CBR%20%2F%3E%20%7B%20%3CBR%20%2F%3E%20%22method%22%3A%22POST%22%2C%3CBR%20%2F%3E%20%22url%22%3A%22beta%2Fteams%2F%5Bteam-id%5D%2Fchannels%2F%5Bchannel-id%5D%2FchatThreads%22%2C%3CBR%20%2F%3E%20%22body%22%3A%7B%20%3CBR%20%2F%3E%20%22rootMessage%22%3A%7B%20%3CBR%20%2F%3E%20%22from%22%3A%7B%20%3CBR%20%2F%3E%20%22user%22%3A%7B%20%3CBR%20%2F%3E%20%22displayName%22%3A%22User%20Name%22%2C%3CBR%20%2F%3E%20%22userIdentityType%22%3Anull%3CBR%20%2F%3E%20%7D%2C%3CBR%20%2F%3E%20%22guest%22%3Anull%3CBR%20%2F%3E%20%7D%2C%3CBR%20%2F%3E%20%22createdDateTime%22%3A%222017-10-07T06%3A30%3A00.000Z%22%2C%3CBR%20%2F%3E%20%22body%22%3A%7B%20%3CBR%20%2F%3E%20%22contentType%22%3A%221%22%2C%3CBR%20%2F%3E%20%22content%22%3A%22blabla%22%3CBR%20%2F%3E%20%7D%2C%3CBR%20%2F%3E%20%22attachments%22%3Anull%3CBR%20%2F%3E%20%7D%3CBR%20%2F%3E%20%7D%2C%3CBR%20%2F%3E%20%22headers%22%3A%7B%20%3CBR%20%2F%3E%20%22Content-Type%22%3A%22application%2Fjson%22%3CBR%20%2F%3E%20%7D%2C%3CBR%20%2F%3E%20%22id%22%3A%220%22%3CBR%20%2F%3E%20%7D%3CBR%20%2F%3E%20%5D%3CBR%20%2F%3E%7D%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20getting%20quite%20confused.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
ZoltanLehoczky
Occasional Contributor

I'm trying to use the POST /teams/{id}/channels/{id}/chatThreads API endpoint to post messages, however I'm experiencing the below problems. Does anybody have an idea what I may be doing wrong?

 

  1. Attaching files doesn't seem to work. In the request I properly supply the ContentType and ContentUrl but no attachment shows up under the messages. I tried multiple data URL formats too ("data:[content type],<base 64 data>", "data:<base 64 data>", "data:[content type];base64,<base 64 data>"), but using the last one. It works if I try it in a browser so I'm confused (though these are bigger images, like around 8MB).
  2. I'm sometimes getting "413 (Request Entity Too Large)" errors when trying to attach files. How big can files attached via the API be, or rather, how large can the whole request be? I don't think it's a limitation with file upload size, because GB-sized files can be attached from within Teams. A 11.5MB request seems to blow it up.
  3. The timestamp doesn't seem to take effect: the timestamp shown in the chat will always be when the message's request was sent, not the older timestamp sent with the request. However the format I'm using is the same the API returns for existing messages.

This sample below request demonstrates what I try with the timestamp and attachments (but here with an HTTPS, not data URL). The message gets created but with the mentioned defects.

{ 
"rootMessage":{
"createdDateTime":"2017-10-20T17:14:52.000Z",
"body":{
"contentType":"0",
"content":"Some message."
},
"attachments":[
{
"contentType":"image/png",
"contentUrl":"https://url-to-image",
"name":null,
"thumbnailUrl":null
}
]
}
}

 

Related, but without answers: https://techcommunity.microsoft.com/t5/Microsoft-Teams/Graph-API-Issues-while-creating-new-chat-thre...

 

Thank you in advance!

4 Replies

4. I have a similar issue with creating threads in a name of a given user. I supply the user object with the correct ID but still the thread and message is created in the name of the user invoking the API request. The user supplied for the message doesn't "stick".

5. Is it possible that batching doesn't work for this endpoint? I get "Resource not found for the segment 'beta'." for firing such request in a batch, see below.

 

{ 
"requests":[
{
"method":"POST",
"url":"beta/teams/[team-id]/channels/[channel-id]/chatThreads",
"body":{
"rootMessage":{
"from":{
"user":{
"displayName":"User Name",
"userIdentityType":null
},
"guest":null
},
"createdDateTime":"2017-10-07T06:30:00.000Z",
"body":{
"contentType":"1",
"content":"blabla"
},
"attachments":null
}
},
"headers":{
"Content-Type":"application/json"
},
"id":"0"
}
]
}

 

I'm getting quite confused.

Nobody with any ideas? The linked thread confirms that attachments are not supported yet, but what about the others?

can you give a example on json payload for posting message with attachments for content type as file.

I've never got it working and as you can see from the above posts, it seems this isn't possible.

Related Conversations
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies
Tabs and Dark Mode
cjc2112 in Discussions on
2 Replies
Early preview of Microsoft Edge group policies
Sean Lyndersay in Discussions on
65 Replies
*Updated 9/3* Syncing in Microsoft Edge Preview Channels
Elliot Kirk in Articles on
202 Replies