Why do I get 401 Client Error when using a webhook to post to Microsoft Flow?

danielhair October 25, 2017

We have seen this issue since the beginning of last month, and we have not been able to get the webhook to work with Flow directly.

I created a temporary solution, where I made a NodeJS Server that would receive the webhook events and would then post to Microsoft Flow. Although this worked fine, this is not a solution we would like, since we would have to host our NodeJS Server. Note, when I opened up a POST request on my node server (using express via `app.post`, I noticed that JIRA would not send the events to me via the webhook. It didn't work until I used `app.all`, which means it would accept all requests (GET, PUT, POST, and DELETE). Once all requests were there, JIRA started to work fine.

Because we received this error on the Cloud product as well. This is when we tried to do this same thing on my self-hosted server. We noticed that it did the same thing when talking to flow directly. it gave the following error -- which I'm sure, the cloud version is doing the same. In the log found in "C:\Program Files\Atlassian\Application Data\JIRA\log\atlassian-jira.log", I found this error occuring everytime a new event occurs in JIRA:

2017-09-28 10:44:37,802 httpclient-callbacks:thread-1 WARN anonymous [c.a.webhooks.plugin.PublishTaskFactoryImpl$PublishTaskImpl] Client error - 401 when posting to web hook at 'https://prod--61-westus-logic-azure-com.mstools.apps.verisk.com:443/workflows/ba4f06a4bb9e447fa97020d0dd9a5aa5/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=j75YAyjbSkzTQ2iLA3ZU5H9rVDEMHpSH-2wSraNNDDc'

Steps to reproduce:
1. Create a webhook in JIRA
2. use this as the url for the webhook to POST to:
https://prod--61-westus-logic-azure-com.mstools.apps.verisk.com:443/workflows/ba4f06a4bb9e447fa97020d0dd9a5aa5/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=j75YAyjbSkzTQ2iLA3ZU5H9rVDEMHpSH-2wSraNNDDc
3. Select all checkboxes in the webhook config.
4. Click save
5. Create or update an issue in any board.
6. The logs should be displaying the error above


This is a very important thing to fix for us, since we do not want to host a "middle-man" application to integrate with JIRA. I have a few screenshots in the description, as well as the log file.

1 answer

1 accepted

4 votes
Answer accepted
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 26, 2017

I found a similar support case for Jira where another user found a solution to a similar problem by adjusting the webhook URL to replace the '%2F' strings in that URL with '/' characters (no quotes for either).   Try changing your URL from:

https://prod--61-westus-logic-azure-com.mstools.apps.verisk.com/workflows/ba4f06a4bb9e447fa97020d0dd9a5aa5/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=j75YAyjbSkzTQ2iLA3ZU5H9rVDEMHpSH-2wSraNNDDc

Into:

https://prod--61-westus-logic-azure-com.mstools.apps.verisk.com/workflows/ba4f06a4bb9e447fa97020d0dd9a5aa5/triggers/manual/paths/invoke?api-version=2016-06-01&sp=/triggers/manual/run&sv=1.0&sig=j75YAyjbSkzTQ2iLA3ZU5H9rVDEMHpSH-2wSraNNDDc

If that doesn't resolve this, then I find that the use of the https://requestb.in/ website to be a helpful tool just to make sure that Jira can reach other sites when a webhook is triggered.  I am interested to see if you can try to use that site instead to test this out, then see what that site shows for the webhook received to learn more about this.  That site can help display other information about the request received.

danielhair October 26, 2017

Oh my gosh! Thank you @Andy Heinzer!

 

This worked right off the bat!

Nithish Gunda March 20, 2018

Hello Andrew,

 

We are doing integration with ServiceNow and when I try to connect to ServiceNow it throws me an error

httpclient-callbacks:thread-108 WARN anonymous     [c.a.webhooks.plugin.PublishTaskFactoryImpl$PublishTaskImpl] Client error - 401 when posting to web hook

 

 

Ben Xiao
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 11, 2020

Bro, you are a hero! Many thanks!

Like Andy Heinzer likes this
Marek Grabowski
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 18, 2021

Oh my God! I was pulling my hair out trying to figure it out in the past 4 hours. @Andy Heinzer you are the best! Thank you very much for this post!

Suggest an answer

Log in or Sign up to answer