I am trying to intergrate database (MS-Sql) and jira to raise a issue on jira using JiraPS but I don't know where to start. Any solution for this.
Hello @Praveen K L
Welcome to the Atlassian community.
Can you describe your scenario in more detail? How are you trying to integrate your database and Jira? What is the flow of events that would lead to an issue being created in Jira?
Thanks @Trudy Claspill Yeah sure.
I have created a database with field inputs like Plugin I'd, Plugin family and few more columns. Now we have to create an issue with these field inputs to be inserted in Jira issue while creating issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What is your level of experience with Powershell?
Are you trying to figure out how to get the data from your database?
Are you trying to figure out how to use the JiraPS module itself just to interact with Jira?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Without JiraPS, I have tried to create issue using the rest api but that gives a 400 bad gateway error.
Code for you reference,
$JiraUrl = "https://my jiraurl/rest/api/2/issue"
$ApiToken = " apitoken"
$Base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(maild:$ApiToken))
$IssueData = @{
"fields" = @{
"project" = @{
"key" = "TEST"
}
"summary" = "This is issue summary"
"description" = "This is the issue description"
"issuetype" = @{
"name" = "Incident"
}
}
}
$RequestBody = $IssueData | ConvertTo-Json
$Response = Invoke-RestMethod -Uri $JiraUrl -Headers @{
Authorization = "BASIC" + $Base64AuthInfo
} -Method Post -ContentType "application/json" -Body $RequestBody
* I am new to both the technology, trying to learn new things. I was unable to figure out the exact reason for 400 bad gateway error. So if the rest api code works fine we can use Rest api for database integration.
Note: JiraPS code is working fine for me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If the JiraPS code is working for you, then what exactly is your question?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well my question is
* To create a issue getting the inputs from the database and attach some inputs in work notes.
* This shall be done using JiraPS.
Request from my side, If possible kindly troubleshoot the rest api method so that it can be helpful for me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Regarding your API issue, HTTP error code 400 is "bad request" not "bad gateway". Those are two very different errors. Which one are you actually getting.
Regarding extracting data from your separate database to use as input to Jira, you won't code that interaction using either the Jira REST API or the JiraPS module. That code is for interacting with Jira, not for interacting with databases. You will need to use other code, either Powershell or the programming language you are using to write the Jira REST API commands, to interact with your database to extract the data from it, and then use that as input to the Jira commands.
You said the JiraPS code is working fine for you. Does that mean you have successfully created a Powershell script with that module and have been able to successfully connect to your Jira instance and create an issue through Powershell code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
* This code returns this following error.
$JiraUrl = 'https://myjiraurl/rest/api/2/issue'
$ApiToken = 'my api token'
$header = @{
Authorization = 'Basic ' +
[Convert]::ToBase64String(
[Text.Encoding]::UTF8.GetBytes("mymailid:$ApiToken")
)
}
$IssueData = @{
Project="TES"
IssueType="[System] Incident"
Summary = "Powershell created support request summary"
Description = "Some description"
} | ConvertTo-Json
Invoke-RestMethod -Uri $JiraUrl -Method Post -Headers $header -Body $IssueData
The above code returns this error
Invoke-RestMethod : The remote server returned an error: (415) Unsupported Media Type.
At line:17 char:1
+ Invoke-RestMethod -Uri $JiraUrl -Method Post -Headers $header -Body $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebE
xception
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
* The JiraPS code which creates the issue from Powershell, working fine without any error.
Set-JiraConfigServer 'https://myjira url'
$password = ConvertTo-SecureString 'my api token' -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential ("my mailid",$password)
New-JiraSession -Credential $creds
New-JiraIssue -Project "TEST" -IssueType "[System] Incident" -Summary "Created using powershell" -Description "Working Fine"
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.