Submitting or reopening a Form using Automation and API

This article is meant to help users who want to use the new Forms API functionality to automatically submit a form or reopen it.

 

Also, if you are looking for a way to manipulate more than one form, please refer to the article below:

 

Workaround steps:

  • Create an Automation rule:
    • First, it will be needed to create an API token for the Web Request process. The Web Request needs your credentials and an API token encoded with base64.  For more information about this procedure, please refer to the documentation below:
      -    - Automation for Jira - Send web request using Jira REST API

    • We need to use the new API functionality of submitting or reopening a form in a Put web request. For example:
      • To reopen a form:

        - The web method will be a PUT:

        PUT https://api.atlassian.com/jira/forms/cloud/{cloudId}/issue/{issueIdOrKey}/form/{formId}/action/reopen

        - The cloudId will be your Cloud ID and not your Org ID. The easy way to get the cloud id is to go to https://<instance>.atlassian.net/admin/jira-service-desk/portal-only-customers. You will get the Cloud id in the URL (e.g.: https://admin.atlassian.com/s/<cloud_id>/jira-service-desk/portal-only-customers)

         Tip: Don't get confused, the Org ID has a /o/ before the ID (https://admin.atlassian.com/O/<org_id>) and the Cloud ID has a /s/ before the ID (https://admin .atlassian.com/S/<cloud_id>).

         

        - The issue ID or issue Key that you are using. To add the issueId or issueKey dynamically, you can use the smart value {{issue.id}} or {{issue.key}}

        - The formId will be in the universally unique identifier "uuid" format. To get it you can use the Forms properties structure below:

        https://<yourCloudURL>.atlassian.net/rest/api/2/issue/<issueId>/properties/proforma.forms

        Screenshot 2023-05-22 at 17.48.05.png

        - To add the formId dynamically, you can use the smart value below:

        {{issue.properties."proforma.forms".forms.uuid}}

        - The automation rule will be as shown in the screenshot below:Screenshot 2024-09-20 at 12.30.47.png

      • To submit a form:

        - The web method will be a PUT:
        PUT https://api.atlassian.com/jira/forms/cloud/{cloudId}/issue/{issueIdOrKey}/form/{formId}/action/submit

        - The steps will be the same as above and the automation rule will be as shown in the screenshot below:Screenshot 2024-09-20 at 12.29.08.png

          

 Note: To call these methods, kindly ensure that the 'Delay execution of subsequent rule actions until we've received a response for this web request' option is selected.

This workaround will work as shown in the screen recording below:

25 comments

Bruna Silva
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 22, 2023

Amazing article!

Like Charles Trilha likes this
Charles Trilha
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 22, 2023

Great article, Proforma legend Bruno!

Marcos Vinicius Araújo Silva
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!
July 14, 2023

Great article.

However, I was successful only in my approval environment according to the image "Instance of Homologation.PNG". In the production instance, I made the same settings and I'm getting the 404 error as shown in the "Production Instance.PNG" image.

Since I'm site-admin I shouldn't have any permission restrictions, right?

And also the Token API was created over here: https://id.atlassian.com/manage-profile/security/api-tokens. That is, the Token API is linked to my email.

I've done several searches here in the community, but unfortunately I wasn't able to succeed in applying this rule to my production instance. Could you help me please?

Instância de Homologação.PNGInstância de Produção.PNG

Like Bruno Altenhofen likes this
Bruno Altenhofen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 17, 2023

Hey @Marcos Vinicius Araújo Silva 

Thank you for your feedback! :D

I think we get resolved your use case at the ticket PCS-194234, but thanks for getting my attention on this I updated the article with the necessary clarification on the information about the Cloud ID, as you can see below:

- The cloudId will be your Cloud ID and not your Org ID. The easy way to get the cloud id is to go to https://<instance>.atlassian.net/admin/jira-service-desk/portal-only-customers. You will get the Cloud id in the URL (e.g.: https://admin.atlassian.com/s/<cloud_id>/jira-service-desk/portal-only-customers)

 Tip: Don't get confused, the Org ID has a /o/ before the ID (https://admin.atlassian.com/O/<org_id>) and the Cloud ID has a /s/ before the ID (https://admin .atlassian.com/S/<cloud_id>).

Thanks and see ya next time!

Like # people like this
Marcos Vinicius Araújo Silva
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!
July 17, 2023


Thanks a lot for the feedback. I ran the tests and it worked.

Thank you very much.

Like Bruno Altenhofen likes this
Pascal Suppers
Contributor
August 2, 2023

Hi, It works fine with 1 form per issue.

The smart value {{issue.properties."proforma.forms".forms.uuid}} provides all uuid's in the issue separated with a comma. The web request can't handle that. Is there a smart value with only the uuid of the explicit form that's being submitted?

Cheers, Pascal

Like # people like this
Florin
Contributor
August 9, 2023

Hello @Bruno Altenhofen ,

Great work with this article, however, I am having trouble making this work.

If you can lend me your expertise I would greatly appreciate it.

This is what I have done so far.

1. generated an API token 

2. I encoded the credentials using base64. so far so good.

3. created the rule as you can see in the screenshots

the web method is a PUT with:
https://****.atlassian.net/jira/forms/cloud/****/issue/{{issue.id}}/form/{{issue.properties."proforma.forms".forms.uuid}}/action/reopen

4. I am getting 
HTTP Status 405 – Method Not Allowed

The method received in the request-line is known by the origin server but not supported by the target resource.

1.PNG2.PNG

Many thanks,

Florin

Like Julián Gramajo likes this
CentricDataProjects September 7, 2023

Hi @Florin have you managed to resolve the error: 

HTTP Status 405 – Method Not Allowed

The method received in the request-line is known by the origin server but not supported by the target resource.

I'm getting this error too. Please help if you have any solution to this.

Looking forward for your 
response

 

Warm regards,

 

Vimbanashe Chambara

Florin
Contributor
September 7, 2023

Hi @CentricDataProjects

Unfortunately, I did not find a fix for it yet. 

Still researching this, If I find something useful I'll comment here.

Thank you,

CentricDataProjects September 7, 2023

@Florin  okay, thank you.

Marco Grima September 18, 2023

Has someone found a way to separate multiple entries in the {{issue.properties."proforma.forms".forms.uuid}} smart value?

 

im getting UUID,UUID as i have 2 forms

Like Nicolas Bleau likes this
Pascal Suppers
Contributor
September 18, 2023

@Marco Grima 

In an automation rule you should create a variable with the follwing syntaxis: {{#issue.properties."proforma.forms".forms}}{{#if(equals(name, "FormName"))}}{{uuid}}{{/}}{{/}}

After that you should create a Send web request with Authorization in the header and the URL https://api.atlassian.com/jira/forms/cloud/your-clou-id/issue/{{issue.id}}/form/{{variablename}}/action/reopen

Like # people like this
Bruno Altenhofen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 20, 2023

Hey @Florin and @CentricDataProjects 

Thank you for your feedback and sorry for my delay in responding here!

So, I noticed from your screenshot that you are using in the "Web request body" the value "Issue data (Jira format)" and not the option "Empty". If you guys are still experiencing the error 405, could you kindly double-check if the option in the "Web request body" is "Empty"?

  • Screenshot 2023-09-20 at 19.16.06.png

Please keep me informed!

Thanks!

Bruno Altenhofen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 20, 2023

Howdy everyone!

I've checked all the comments and noticed that there are some related to how to handle/manipulate forms separately.

Therefore, allow me to share with you this article that explains how to manage multiple forms separately:

Thanks!

Like Cissa Tarasconi likes this
André Cohen
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!
November 2, 2023

Hi @Bruno Altenhofen I am also facing the same issue as @Florin and @CentricDataProjects

I am using Web Request body as "Empty" but still getting the same error - HTTP Status 405 – Method Not Allowed.

How to solve it?

André Cohen
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!
November 2, 2023

Hi @Florin and @CentricDataProjects I actually fixed the issue now. I was using my endpoint instead of using https://api.atlassian.com/

My bad as @Bruno Altenhofen instructions were correct. Thank you, this is really great while https://jira.atlassian.com/browse/JSDCLOUD-10671 does not get implemented.

Like Bruno Altenhofen likes this
Bruno Altenhofen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 8, 2023

Hey @André Cohen 

Glad to hear that you were able to fix it, and thanks for your feedback! :D

Like André Cohen likes this
Cissa Tarasconi
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!
November 16, 2023

Amazing article!

Really helpful :)

Like # people like this
Ralph Gerald Varon
Contributor
January 30, 2024

Amazing Article as always!

 

We need this to be natively available in Automation for Jira itself, but great workaround!

Like Bruno Altenhofen likes this
Bruno Altenhofen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 31, 2024

Thanks @Ralph Gerald Varon :D

Jael Carvalho February 2, 2024

Hey, @Bruno Altenhofen , taking the question of @Pascal Suppers again, I'm in the same kinda of trouble:

"It works fine with 1 form per issue.

The smart value {{issue.properties."proforma.forms".forms.uuid}} provides all uuid's in the issue separated with a comma. The web request can't handle that. Is there a smart value with only the uuid of the explicit form that's being submitted?"

Could you help with these?

 

 

Shivendra Singh Chouhan
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!
April 4, 2024

Hi @Bruno Altenhofen

Thankyou for this article.

I am trying to create this rule in my jira instance, but I am getting a 404 error. I have checked the url for the request multiple times. I have ensured that I am using cloud id in the url and not the org id. 

I have tried with different API tokens. I have checked the permissions I have for the project and the issue. All looks good. 

I have tried with a different url - something like below, and the rule is running without error in this case. 

https://<jira_instance>/rest/api/3/customField/10287/option

But when I use the url in the below format, I get 404 error. - 

https://api.atlassian.com/jira/forms/cloud/{cloudId}/issue/{issueIdOrKey}/form/{formId}/action/reopen

 

Are there any suggestions of the things I can try to resolve this error. 

Thanks.

Mario Coluzzi
Contributor
July 22, 2024

Hi @Bruno Altenhofen 

Interesting solution.

My primary security concern is around the token. As a Site Admin, if I were to utilize a token generated with my ID, individuals with admin privileges in JSM could potentially gain unauthorized access to the system and misuse it for malicious purposes.

I am uncertain whether using a ServiceAccount token would yield similar results. While I have not conducted comprehensive testing on the entire solution yet, I intend to share my discoveries.

As a rule of thumb, it is strongly advised to use an Admin token under any circumstances, especially when hard-coded in a script available to other users.

Jakub Szymański September 23, 2024

Hello,

Dear community. 

I tried everything I could think of to test it however, it did not work. I get a 405 error all the time.
I tried to see all the differences in the screenshots of your conversation.
I caught the differences in the “Web request URL” section between “API” and instance name.
As well as in the “Headers” section between the key “X-ExperimentalAPI” and “Accept”.

I tried swapping these differences in various ways however every single one did not work.
Two times I checked the “cloudID”, form uuid as well as API token encoded with base64.
I am sure I have the correct data. Is anyone able to suggest me what to pay attention to?

I would be very grateful for your help.

Thank You 

Zrzut ekranu 2024-09-23 120012.png

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events