An unofficial way to monitor a JSM mail handler for errors

34 comments

tobias December 9, 2024

Hi @Mark B Wager 

The API seems to work correctly. If I switch to another user that is not a project administrator or incognito mode, it fails.

I get this data from the API string.
{"data":[{"id":17234,"mailChannelId":11,"mailItemId":17234,"handlerName":"Service project Mail Handler","resultStatus":"FAILED","message":"Current user is not active","fromAddress":"inactiveuser@jira.nu","mailChannelName":"emailchannel@jira.nu","subject":"Sv: Radera domän","issueKey":"","noOfRetry":0,"updatedDateTime":"2024-11-28 09:34","createdDateTime":"2024-11-28 09:34"},{"id":17227,"mailChannelId":11,"mailItemId":17227,"handlerName":"Service project Mail Handler","resultStatus":"FAILED","message":"Current user is not active","fromAddress":"inactiveuser@jira.nu","mailChannelName":"emailchannel@jira.nu","subject":"Radera domän","issueKey":"","noOfRetry":0,"updatedDateTime":"2024-11-28 06:27","createdDateTime":"2024-11-28 06:27"}],"totalPages":1}

 

I attached an image for the web request settings. 

web request.png

Mark B Wager
Contributor
December 9, 2024

Hi Tobias,

If the API works then your command is correct. So, the issue must be 'permission' related, since you mention switching to another user.

The API authentication token you use represents the "user". So, to access the project and it's settings, you need to make sure the user has proper access in the project. They'll need a JSM license, be a role member, and have permissions that allow them the access (e.g., Project Admin). I can't remember if they need to actually be a Jira admin. I don't think so.  

We created a special service account and use this for the user. This way we can assign access that is separate from our admins, for tracking and so things don't break when people change roles or leave the company.

Does this work if you create and use your own API key?  You might want to create a test user and create an API key for it and try it with that.  It sounds like you have things right, but just need to work out the user permissions, as described above.

Mark

tobias December 10, 2024

@Mark B Wager 

Does this article apply to Jira data center, or is it just for Jira cloud?

I've tried with my own user (global Jira administrator) and API key, and the automation still keeps failing. If I paste the URL into my browser, it returns the correct data. 

If I switch to Bearer instead of Basic and my access token, the automation "succeeds", but the webhook returns no data (I tried changing from true to false) and the e-mail that got sent was empty.

tobias December 10, 2024

@Mark B Wager 
We finally got everything to work
* We switched to using Bearer instead of Basic
* Instead of API key, we are using Personal Access Tokens
* "webhookResponse" instead of "webResponse"

Thank you for your help!

Like Mark B Wager likes this
Cyril January 27, 2025

Thank you Yuri for this workaround and all for the additional tips

It works fine for me as long as I do not use "from={{epochtimestamp}} in the get request.

As soon as I use it, I get an error 400...

[mysiteURL]/rest/jira-email-processor-plugin/1.0/mail/audit/process/CHANNELxxxxxx?from={{epochtimestamp}}&statuses=FAILED

I have tried several {{epochtimestamp}} values, but whatever I use, it always fails... Any idea ?

(even with only {{now}} in the variable, it fails)

Log (of the variable)
2025-01-27T13:15:25.8+0000


Send web request
27/01/2025, 14:15:25

Unable to publish the web request - received HTTP status response:
400
Error found in the HTTP body response:

Thank you in advance !

Cyril

 

Mark B Wager
Contributor
January 27, 2025

Hi @Cyril 

Be sure you re-read the thread instructions carefully. The {{epochtimestamp}} is NOT a function, it is  a VARIABLE that is being created and then used as a filter in the URL.  You can see my example usage in my earlier comment here

You're getting this error because it can't find the defined variable (which you can name anything you want).  Try adding a variable with the value Yuri or I suggest. And, you don't need to use the variable/filter at all, unless you're trying to return only a certain range based on a time frame.

Hope this helps,

Mark

Cyril January 27, 2025

Hi @Mark B Wager 

thank you for your feedback.

I did create the variable (and added a log to be sure it was correct when I saw it was failing)

Whatever the smart value in the variable, it always fail. (I have tried a lot, including the ones proposed in this thread)

below the automation

2025-01-27 15_06_13-Rule builder - Automation - Global Support - Jira.png

I really don't understand what I am doing wrong...

thx

Cyril.

Mark B Wager
Contributor
January 27, 2025

Hi @Cyril can you post the screenshot of the smart value you're filling the variable with, as shown in the main post?

 

Cyril January 27, 2025

Hi @Mark B Wager ,

I found the issue - the time was not turning into a real epochtime, but still having a formated date

I found out by re-writing the variable instead of using copy-paste (maybe an hidden character somewhere)

before (not working)

Log (of the variable)
2025-01-27T13:15:25.8+0000

after (working)

Log (of the variable)
1737952829520

All good now !

Sorry for the disturbance and thank you for the assistance

best

Cyril.

Like Mark B Wager likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events