cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

HTTP request trigger - requiring Content-Type

Hi all,

I am building a flow where I would like to require a specific content-type in the http header.

If I build an expression which checks the content-type, it works fine if the header exists, but if it *does not* exist, the flow the fails with "invalid template" because the triggeroutputs()['headers']['content-type'] does not exist.  HTTP 500 is returned with "bad gateway", but I want the flow to fail more gracefully instead (return HTTP 415 - Unsupported media type to the client).


I tried to catch this error by setting a variable to the Content-Type and then different "Run after" actions but the flow does not reach that point, the invalid template error just terminates the flow.

 

Does anyone know a way that I can trap this error and prevent the flow failing?  

 

Thanks!

3 REPLIES 3
v-yuazh-msft
Community Support
Community Support

Hi @Anonymous,

 

The "Run after" would only work after actions, and the "Run after" doesn't work after a trigger.

I afraid that there is no any way to achieve your requirement in microsoft flow currently.

 

Best regards,

Alice

Anonymous
Not applicable

Thanks for the reply.

 

The flow does not fail in the trigger itself, but when I use a condition in the flow to check for the Content-Type header in a condition

@@triggeroutputs()?['Headers']['Content-Type'] .  If the Content-Type is not specified in the https request, the "Invalid Template" error occurs.  But this seems to fail the entire flow and return an http 500 response rather than execute the "Run After".

 

Is that the expected behaviour ?

 

Many thanks for your help!

Cheers,

Shane

Hi @Anonymous,

 

It is the expected behaviour for "Invalid Template" error if the Content-Type is not specified in the https request.

Please make sure you have specified the Content-Type in the https request.

 

Best regards,

Alice

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (1,316)