Question

Failed to create an HTTP request in Microsoft Team: Invalid URL

  • 8 July 2023
  • 9 replies
  • 302 views

I want to send replies to a Teams Channel message.  I have surmised that I need to send an API request.

My zap is all set up and working to post a Teams Channel message.

I found this article:  https://learn.microsoft.com/en-us/graph/api/chatmessage-post-replies?view=graph-rest-1.0&tabs=javascript

HTTP request is formatted POST /teams/{team-id}/channels/{channel-id}/messages/{message-id}/replies

I tested this HTML code in Microsoft Graph to see if it would send a reply.

(This is dummy code from the article--not my teams/channel/message ID.)

POST https://graph.microsoft.com/v1.0/teams/fbe2bf47-16c8-47cf-b4a5-4b9b187c508b/channels/19:4a95f7d8db4c4e7fae857bcebe0623e6@thread.tacv2/messages/1616990032035/replies
Content-type: application/json

{
  "body": {
    "contentType": "html",
    "content": "Hello World"
  }
}

After fiddling with permissions for Microsoft Graph, I got it to work .  The text “Hello World” posted as a Teams Channel reply to the original message.

I now want to add this to my Zap as a Teams API Request (I think).  If I were to do that, how would I correctly fill out the Teams API Request Action?

What is incorrect from this: 

 

I am getting this error: 

 

Is this the correct Action?  Do I need to add another permission in Azure to make Zapier play nice with a Microsoft API Request?

I am so close but I can’t take it past the finish line.

 


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

9 replies

Userlevel 7
Badge +14

Hi @Carl Christensen 

Good question.

Add this JSON to the Body section.

{
"body": {
"contentType": "html",
"content": "Hello World"
}
}

 

 

I added the JSON to the body message, and I got the same error.

 

Here is the MS Graph Request with the confirmation code that it worked.  I triple checked the URL and the body code.  

What am I missing?

 

 

Userlevel 7
Badge +11

Hi @Carl Christensen! 👋

I’ve seen cases before where a @ symbol caused a similar invalid URL error when using an API Request (Beta) action.

Can you try swapping out the @ symbol in the URL field for it’s URL encoded equivalent: %40

Keen to ensure you’re all set here so please do keep us in the loop on how that goes! 

I changed the “@” sign to the HTML equivalent %40

 

Oooh, that is a lot closer.  Now it says “Raw request failed”

Same inputs as above.

Userlevel 7
Badge +11

Thanks for giving that a try, @Carl Christensen. Let’s see what we can do about this new error! 

Hmm, perhaps you don’t need to reference the body since you’re putting that into the Body field? I’m wondering if having the following code in the Body field would work:

{
"contentType": "html",
"content": "Hello World"
}

I’m assuming you’ll still need the { } curly brackets there, I’ve not tested this so can’t confirm for certain whether that’s definitely the case or not.
 
Could you give that a try and let us know if that sorts it?

I tried changing the body field to 

{
"contentType": "html",
"content": "Hello World"
}

And

"contentType": "html",
"content": "Hello World"

Same error--”Raw request failed”

Userlevel 7
Badge +14

@SamB 

There may be a bug with this Zap action behind the scenes with how data is being sent as part of the API request.

Userlevel 7
Badge +11

Yes, quite possibly @Troy Tessalone! That API Request action is still in beta so it’s expected that there may be a few glitches and bugs that could pop up still.

@Carl Christensen - it may well be worth reaching out to our Support Team to investigate further in case this is indeed a bug. Before doing so I just wanted to double-check that the API Request action is connected to a work, rather than personal, Microsoft account? If it is, I wonder if it might be missing certain permission scopes that are required
596671a1e01d20d197089e9b8fc086b4.png

I know it doesn’t reference the permissions in the error specifically, but thought it best to double-check on that just in case. 

Please do keep us updated on how you get on!

The permissions you reference are the Microsoft Graph permissions to call the MS Teams Reply to message API. Microsoft Graph is working fine.  I am able to reply to messages in the Graph explorer no problem. 

I will reach out to Support.  To be clear, I am trying to reply to a Teams channel message.  MAKE has a prebaked task that can do this.