Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Send WebHook via JMWE

Hello,

Hi everyone, we already use JMWE, and we need to send a WebHook similar to the sending already available in automation, see attached how it is done in automations, we need to do it in the same way via JSON:

And we also need to know where we put the shipping data:

Web request URL*
Headers
HTTP method*
Web request body*
Custom data*

Something like:
{
"options": [
{
"value": "{{key}} {{summary}}",
"disabled": false
}
]
}

3 answers

1 accepted

2 votes
Answer accepted
David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 24, 2023

Hi @Henrique Degan 

you can use a Build-your-own (JMWE app) post-function, and use the callRest filter: https://appfire.atlassian.net/wiki/spaces/JMWEC/pages/465242995/callRest 

There are a few examples on that page, let me know if you need additional help.

Hello @David Fischer _Appfire_ , thank you very much for your feedback,

I'm sorry for the lack of knowledge, but I'm still confused, in this case where I put the information is in the Post Function? where can I use this callReset to perform?

In this case, we have JIRA's own WebHook, but there is no place to put the Body information, etc...

 

WEBHHOK3.pngWEBHHOK2.png

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 25, 2023

Hi @Henrique Degan 

why would you need to put any code in a Jira webhook? What are you trying to achieve exactly? Or rather, when? Can you describe your use case?

"Sending a webhook call" (or rather "making a REST API call" would be the proper expression) is not at all related to Jira WebHooks, which are simply a way to react to internal Jiera events.

If you want to send the REST API call during a workflow transition, you'll need to add a  Build-your-own (JMWE app) post-function to that transition. If you want to send the REST API call in response to another Jira event, you can add the Build-your-own (JMWE app) post-function to an Event-based Action.

Hi @David Fischer _Appfire_  thank you very much for your feedback, it was very useful,

I managed to make a query via test but I can't do the PUT, I tried something like this:

{{ "https://instancia.atlassian.net/rest/api/3/issue/TVS-4925" | callRest(
options = { "auth":
{"username" : "email",
"password": "password"
}
})
| dump(2)}}
{{ callRest(verb="PUT",
body={
"fields": {
"summary" : "TESTS"
}
}

But it didn't work!

Error:

There was an error during the rendering of your template

Message:
(string)
  TypeError: Cannot read properties of null (reading 'type')
David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 25, 2023 • edited Oct 26, 2023

HI @Henrique Degan 

first of all, if you're trying to call your Jira instance, you should use the callJira filter, which will automatically authenticate you with Jira.

Then the syntax becomes:

{{ "/rest/api/3/issue/TVS-4925" | callJira(
verb="PUT",
body={
"fields": {
"summary" : "TESTS"
}
})
}}

And if you want to modify the current issue, you can do:

 {{ "/rest/api/3/issue/:issuekey" | callJira(
verb="PUT",
params={issuekey:issue.key},
body={
"fields": {
"summary" : "TESTS"
}
})
}}

Please look at https://appfire.atlassian.net/wiki/spaces/JMWEC/pages/465243039/callJira for details. 

Hello,
I think I'm eating cake on some information:

 

{{ "myinstance.atlassian.net/rest/api/2/issue/:TVS-4925" | callRest(
verb="PUT",
params={issuekey:issue.key},
body={
"fields": {
"summary" : "TESTS"
}
})
}}

 

WEBHHOK4.png

 

It is showing an error

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 25, 2023

Hi @Henrique Degan 

You're supposed to use my code as it is:

- the url starts with /rest

- :issuekey in the url should be left as is. It will be replaced at execution time by the value passed in the params attribute:

params:{issuekey:issue.key}

(notice that "issuekey" is the same in params and the url. You could use "foo" instead, it's just the name of the placeholder that callJira will replace automatically) 

Hello, @David Fischer _Appfire_ 

I'm not really leaving the place, I'm putting it as you told me and it doesn't work, I don't know where I could be going wrong:

 

WEBHHOK6.png

Error return:

 

WEBHHOK7.png

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 26, 2023

Hi @Henrique Degan 

You need to use callJira not callRest. In my initial response, I didn't know you were calling Jira not an external service, and then I forgot to replace the filter in the code snippet. Sorry about that.

I'm updating my previous response accordingly.

Hello @David Fischer _Appfire_ 

It worked very well here, thank you very much, can I take advantage of this channel and ask my next question?

In this case, for example, for me to push a value from one field to another via Rest:
In JSON in Body I do it like this:

"customfield_10038" : "{{assignee.displayName}}"

But when I do it in Rest in JMWE, the same typed speech appears.

I tried something like this:

{{ "/rest/api/3/issue/:issuekey" | callJira(
verb="PUT",
params={issuekey:issue.key},
body={
"fields": {
"summary" : "{{issue.customfield_10039}} - {{issue.customfield_10040}}"
}
})
}}

It came back to me:

WEBHHOK8.png

But it was supposed to return this value here + this:

WEBHHOK9.png

 

Can you help me?

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 27, 2023

Hi @Henrique Degan 

You cannot put a template expression inside a template expression. But you can use standard JavaScript syntax:

summary" : issue.customfield_10039 + " - " + issue.customfield_10040

 Of course, that will only work if both fields are text or number fields. For other types, you'll need to use the "issue fields" help tab to figure out how to access a text property of the object representing the value. For example, if customfield_10039 is a  Single User picker, you could use 

issue.customfield_10039.displayName

Hello @David Fischer _Appfire_ 

It worked very well, I just put the parameter like this to accept it:
"summary" : issue.fields.customfield_10039 + " - " + issue.fields.customfield_10100

Now we can go to the 3rd step if we can:

 

{{ "/rest/api/3/field/customfield_11401/context/11568/option" | callJira(
verb="POST",
params={issuekey:issue.key},
body={
"options": [
{
"value": issue.fields.issuekey + "-" +issue.fields.summary,
"disabled": false
}
]
}
})
}}

But it is generating error:

 

There was an error during the rendering of your template

Message:
(string)
  TypeError: Cannot read properties of null (reading 'type')
David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 27, 2023

Try removing the params parameter, which you don't need for that call. Also, it looks like you have one too many }

Hello @David Fischer _Appfire_ 

I tried to apply it like this:

{{ "/rest/api/3/field/customfield_11401/context/11568/option" | callJira(
verb="POST",
body={
"options": [
{
"value": issue.fields.issuekey + "-" +issue.fields.summary,
"disabled": false
}
]
}

But it's still returning an error, could it be that I'm still doing something wrong?

 

WEBHHOK10.png

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 30, 2023

Hi @Henrique Degan 

you're missing the closing ) and then }} at the end:

{{ "/rest/api/3/field/customfield_11401/context/11568/option" | callJira(
verb="POST",
body={
"options": [
{
"value": issue.fields.issuekey + "-" +issue.fields.summary,
"disabled": false
}
]
}
)
}}

  

Hello @David Fischer _Appfire_

Very good, the error no longer generated here, however, when I run the test and when I run the test on the function, it is also not imputing the information in the given URL:

 

It would look like this: When I click on "WebHook Tests"
Post-Function executes the script:
After executing it, it imputes the information in the context of the field!

And it's not imputing!
I think I must still be doing something wrong!

 

{{ "/rest/api/2/field/customfield_11401/context/11568/option" | callJira(
verbo="POST",
body={
"opções": [
{
"valor": issue.fields.issuekey + "-" +issue.fields.summary,
"disabled": false
}
]
}
)
}}

 

WEBHHOK11.png

The value should appear here:

WEBHHOK12.png

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 30, 2023

Hi @Henrique Degan 

you have translated the code to Portuguese! You need to use English in the code (as I provided earlier)

Also, if you want to see the result of the REST call, you can add | dump(2) when you're testing in the tester:

{{ "/rest/api/3/field/customfield_11401/context/11568/option" | callJira(
verb="POST",
body={
"options": [
{
"value": issue.fields.issuekey + "-" +issue.fields.summary,
"disabled": false
}
]
}
) | dump(2)
}}

Hello @David Fischer _Appfire_ 

Wow, that was ugly, I'm sorry!!!! Really, I'm so crowded here that I didn't even notice!

Hello @David Fischer _Appfire_ 

It worked perfectly here, thank you very much for your help, it was very useful!

Hello @David Fischer _Appfire_ ,

 

I'm facing a similar problem, and I was wondering if you could help me. 

 

I'm transferring our Jira's "Web request" automation rules to JMWE. 

 

As such I'm trying to build a post-function that will post HTTP request to an internal API endpoint. 

 

Here is the code I got this far:

{# Set the URL of the API endpoint #}
{% set url = "https://mycompany/endpoint" %},

{# Set the headers for the request, including the auth token #}
{% set headers = {
"Content-Type": "application/json",
"Authorization": "Token mytoken"
} %}

{# Set the body of the request, using the issue data #}
{% set body = {
"issueKey": issue.key
} %}

{# Make the POST request and store the response #}
{% set response = url | callRest( verb = "POST", headers , body ) | dump(2) %}

 

However, I'm having trouble getting pasted the Authorization. I'm getting an error 403.Capture d’écran 2023-10-26 142550.png 

I've 2nd checked the token, and it works. I'm guessing it may be something linked to the plug-in syntax ? 

 

Would you be able to help me out?

 

Thanks in advance!

Hugo 

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 26, 2023

Hi @Hugo Michelez 

That's probably because you need to use named parameters to the callRest filter, which you did for the "verb" parameter but not the others. You need "body=body,headers=headers"

@David Fischer _Appfire_ Thanks for the quick response!

I updated the parameters as recommended:

 

{# Set the URL of the API endpoint #}
{% set url = "https://company/endpoint" %},

{# Set the headers for the request, including the auth token #}
{% set headers = {
"Content-Type": "application/json",
"Authorization": "Token abcdefg"
} %}

{# Set the body of the request, using the issue data #}
{% set body = {
"issueKey": issue.key
} %}

{# Make the POST request and store the response #}
{% set response = url | callRest( verb = "POST", headers = headers , body = body) | dump(2) %}

Unfortunately, I having the same error.

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 26, 2023

There is actually no headers parameter to the callRest filter, did you check the documentation?

To pass a header value, you pass it in a headers attribute of the options parameter:

options={headers:headers}

 You should also check this documentation: https://www.npmjs.com/package/request#http-authentication

Like Hugo Michelez likes this

It worked! Thanks a lot for your help and your time

I did read the documentation, however, as I didn't use the named parameters you mentioned in your previous message, even putting the headers in the options did not work.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events