myurl/rest/api/3/search/jql?jql=project=xxxx shows data when opened in IE . But when run from powershell with below command not retuning any data.
Invoke-RestMethod -Method 'Get' -Uri $jira_url -Authentication Basic -Credential $credential -ContentType "application/json" -OutFile ./jiras-current-project.json
Hi @prakashgss
I have verified that the Jira API works correctly using both cURL and PowerShell. Below are the detailed steps for both options.
⸻
🔹 Option 1: Using cURL in the Terminal (Recommended)
1️⃣ Get the API Token
If you don’t have an API token yet:
2️⃣ Run the command in Terminal
Replace "your_email@domain.com" and "your_api_token" with your Atlassian credentials and yourdomain and project in GET method:
curl -u "your_email@domain.com:your_api_token" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-X GET "https://yourdomain.atlassian.net/rest/api/3/search?jql=project=XXX"
🔹 To save the response to a JSON file:
curl -u "your_email@domain.com:your_api_token" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-X GET "https://yourdomain.atlassian.net/rest/api/3/search?jql=project=PROJ1" \
-o jiras-current-project.json
✔ This will generate a jiras-current-project.json file in your current directory.
⸻
🔹 Option 2: Using PowerShell
If you prefer to use PowerShell, follow these steps:
1️⃣ Create a PowerShell script file
Run in Terminal:
nano jira_request.ps1
Copy and paste the following code into the file, replacing "your_email@domain.com" and "your_api_token" with your credentials and yourdomain and project in GET method:
$email = "your_email@domain.com"
$api_token = "your_api_token"
$auth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("${email}:${api_token}"))
$headers = @{
Authorization = "Basic $auth"
"Content-Type" = "application/json"
Accept = "application/json"
}
$jira_url = "https://yourdomain.atlassian.net/rest/api/3/search?jql=project=XXX"
$response = Invoke-RestMethod -Method 'Get' -Uri $jira_url -Headers $headers
$response | ConvertTo-Json -Depth 50 | Out-File -Encoding utf8 "./jiras-current-project.json"
Save and close (CTRL + X, then Y, and ENTER).
2️⃣ Run the script in PowerShell
In the Terminal, start PowerShell:
pwsh
Run the script:
./jira_request.ps1
✔ This will generate a jiras-current-project.json file with the Jira response.
⸻
📌 Verification
To check if the JSON file was generated correctly:
cat jiras-current-project.json
⸻
🚀 Conclusion
With these steps, you can test and save the Jira Cloud API response in two ways: using cURL in Terminal or PowerShell with a script. Both options have been verified and work correctly.
If this response was helpful, don’t forget to mark it as accepted! 🚀
Can you try with this script? The difference in calling is to pass the Authorization in header.
$headers = @{
Authorization = "Basic YourPAT"
}
$response = Invoke-RestMethod -Uri "https://your-instance.atlassian.net/rest/api/3/myself" -Headers $headers -Method Get
$response
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did not work . Many REST APIs have been working for me except this one to get issues in project . It seems OAuth2.0 should be used to register and app and get required token for specific APIs. It is mentioned here.
Thanks for your time .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.