I'm using Confiforms to try and build a WebService Request to try and create a set of tasks based on the number of items that the user supplies into a Text field. The Text field format should be a comma separated list, and is stored in "TestScriptsToRun".
I have all the linkages working, and am able to submit single creates, but I can't get the bulk to work...
Here's my code.
{ "issueUpdates":[ #set($TSToRun = "[entry.TestScriptsToRun.split(,).toArray(')]") #foreach ($script in $TSToRun) { "fields": { "project": { "key": "PRJT" }, "summary": "Run $script for [entry.SourceStory.key]", "components": [{"name": "Software"}], "description": "\n\n**Automatically Generated from Confluence**\n\n", "labels": [ "AutomatedTask" ], "issuetype": { "name": "Story" } } #if($script != $TSToRun.get()) }, #end #end } ] }
Here is the error I receive.
Thanks for your help!
Hi @John Hamilton and welcome to this community
In ConfiForms the template are processed as follows:
In other words the
#set($TSToRun = "[entry.TestScriptsToRun.split(,).toArray(')]")
Does not get the value from TestScriptsToRun field when this is processed as a Velocity template
Alex
@nurac: Thanks! Any ideas on how to get this where I want it? If [entry.TestScriptsToRun] looks like:
TEST_123_01, TEST_123_02, TEST123_03
is there a way to get the velocity template to work?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Something like this
#foreach ($script in ${TestScriptsToRun.split(",")}) ${script} <br/> #end
(of course not the <br/> in there... I just did a test with a PlainView for a quicker debugging method)
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Alex! I got the above working in PlainView, now I'm working on the second condition (the if statement) that will allow me to push add in the correct closing bracket for the JSON, but only for the last item in the split.
Here's what I've got. I can't get the equality to fire...
#foreach ($script in ${TestScriptsToRun.split(",")}) ${velocityCount} ${script}<br/> [entry.TestScriptsToRun.split(",").get()] <br/> #if(${script} == ${TestScriptsToRun.split(",").get()}) "Addition at the end" <br/> #end #end
Appreciate your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I dont think there is a velocityCount - as Confluence uses a pretty old version of Velocity templates https://velocity.apache.org/engine/1.7/user-guide.html
The best option is to iterate through and get the last one set to some extra variable you define on top of the foreach loop
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Awesome! Took a while, but I finally got it working, and it seems to create the right JSON. Unfortunately, now I'm getting a different error.
Requested to https://<server>/rest/api/2/issue/bulk has resulted in an error. Response code = 400 (method ='POST'). Response contents: {"errorMessages":["Unexpected character ('Â' (code 194)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.apache.catalina.connector.CoyoteInputStream@26a77e56; line: 3, column: 3]"]}
Not sure what to do here. To troubleshoot, I copied the script from the "No Format" box to the "PlainView" box with no changes. The JSON that is produced works in a JSON parser and validator against the JIRA API.
I have success when I create a single issue without any of the Velocity scripting (through the create single issue call), but I can't get it to work through this call.
Here's my current code:
#set ($myLast = "") #foreach ($script in ${TestScriptsToRun.split(",")}) #set ($myLast = $script) #end { "issueUpdates":[ #foreach ($script in ${TestScriptsToRun.split(",")}) { "fields": { "project": { "key": "PRJT" }, "summary": "Run $script for [entry.SourceStory.key.escapeJSON]", "components": [{"name": "Software"}], "description": "\n\n**Automatically Generated from Confluence**\n\n", "labels": [ "AutomatedTask" ], "issuetype": { "name": "Story" } } #if(${script} != ${myLast}) }, #end #end } ] }
Any idea what I've missed?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could be a last "," ?
Jira is known to be very tentative about the JSON posted... and vague about the error messages
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The error states it's getting some form of
'Â' (code 194)
in the file. I have no idea how it would get that.
I put the JIRA API JSON Schema and my resulting JSON into a parser, and it all looks just fine... I don't see any extra commas anywhere.
Here's the raw output from the "Plainview" box.
{ "issueUpdates":[ { "fields": { "project": { "key": "PLGN" }, "summary": "Run PLGN_999_99 for PLGN-3002", "components": [{"name": "Software"}], "description": "\n\n**Automatically Generated from Confluence**\n\n", "labels": [ "AutomatedTask" ], "issuetype": { "name": "Story" } } }, { "fields": { "project": { "key": "PLGN" }, "summary": "Run PLGN_999_98 for PLGN-3002", "components": [{"name": "Software"}], "description": "\n\n**Automatically Generated from Confluence**\n\n", "labels": [ "AutomatedTask" ], "issuetype": { "name": "Story" } } } ] }
And here's what it looks like when prettied up a little.
{
"issueUpdates": [
{
"fields": {
"project": {
"key": "PLGN"
},
"summary": "Run PLGN_999_99 for PLGN-3002",
"components": [
{
"name": "Software"
}
],
"description": "\n\n**Automatically Generated from Confluence**\n\n",
"labels": [
"AutomatedTask"
],
"issuetype": {
"name": "Story"
}
}
},
{
"fields": {
"project": {
"key": "PLGN"
},
"summary": "Run PLGN_999_98 for PLGN-3002",
"components": [
{
"name": "Software"
}
],
"description": "\n\n**Automatically Generated from Confluence**\n\n",
"labels": [
"AutomatedTask"
],
"issuetype": {
"name": "Story"
}
}
}
]
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you post the same json directly using the Jira REST API?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For example as shown in the official examples by Atlassian https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After a little trial and error, I was able to get it to post successfully using the command line. I have created stories in JIRA from the raw JSON. I got it to work with both the single line, and with the "pretty" formatted line. Everything looks right on the individual issues.
Unfortunately, still no luck using the Confiforms Webservice Call...
Is there any way to pickup the exact JSON that's being sent by Confiforms?
Any other ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The best way is to check with Confluence logs - that should be logged there
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately, we can't find it in the Confluence logs. We've got Debug turned on for the form, and there was additional debugging info, but couldn't find the JSON that was sent. Any other ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
If you have enabled DEBUG level logs for ConfiForms as per https://wiki.vertuna.com/display/CONFIFORMS/How+to+enable+debug+logging+for+ConfiForms+app then the logging is very verbose - it logs the JSON it is about to post and logs a lot of details if the request has failed
You should see something like from a ConfiForms logger
"Could not complete request, <SOME_MESSAGE_HERE> Used input: '<YOUR_JSON>'"
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First problem solved, it was barfing on tab characters in the input. So, if anybody else gets Code 194 errors, it's likely due to somebody (in this case me) using tab characters instead of spaces. Really, I should know better by now!
Onto the second problem: It appears as though we aren't authenticating with the JIRA instance through the webservice call. The admins don't believe this is doable in our security context, so I'm stuck again, and may be forced to using the "Create JIRA Issue" call (which I know works, but only creates a single issue).
Any ideas on how to take a single form submission and create multiple form entries (to trigger multiple "Create JIRA Issue" IFTTT calls?
If not, I may have to resort to "Here's your Excel Template. Fill it out, and upload..."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can call any API endpoint of the app connected through the application link using the https://wiki.vertuna.com/display/CONFIFORMS/Configuring+ConfiForms+IFTTT+actions+and+rules#ConfiguringConfiFormsIFTTTactionsandrules-ApplinkService
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.