Submitting or reopening a Form using Automation and API

Work has already started on the new Forms API functionality and we now have some experimental APIs available for use. So now Marketplace Partners can already integrate forms into their products.

For more information, please refer to the features below:

 

As a workaround to the feature request "Forms Automation: Lock/submit/reopen form on status change", this article is meant to help users who want to use the new experimental features of the Forms API 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 2023-05-22 at 17.59.44.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 2023-05-22 at 18.09.49.png

          

 Note: To call experimental methods the "X-ExperimentalApi" and "opt-in" header must be provided on the web request headers.

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

23 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 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 Charles Trilha likes this
Marcos Vinicius Araújo Silva 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 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 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 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

Pascal Suppers 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 Ralph Gerald Varon likes 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 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 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 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 Palmeiro de 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.

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events