Today - I had to update my API token -- and now I am getting back {"issues":[],"isLast":true} in my VBA code
Here is my code:
Public Sub TESTVBA()
Dim url As String
Dim xhr As New MSXML2.XMLHTTP60
Dim auth As String
url = "https://jciproducts.atlassian.net/rest/api/3/search/jql?jql=issuekey=GIV-177031&fields=*all"
auth = "Basic " & Base64Encode("MyEmail@domain.com:yourAPIToken")
xhr.Open "GET", url, False
xhr.SetRequestHeader "Authorization", auth
xhr.SetRequestHeader "Accept", "application/json"
xhr.SetRequestHeader "User-Agent", "PostmanRuntime/7.29.0"
xhr.Send
Debug.Print xhr.ResponseText
End Sub
Note: I have to do the User-Agent - otherwise it tells me result is not supported in the browser.
I have to use MSXLM2.XMLHTTP60 - which I hope is OK?
Hi @Chris DeNardis , welcome to the Community!
First thing to check is obviously making sure about the issue exists or not. Once you are sure that the issue exists and your user (that you use in integration) have access to the "GIV-177031", you may try to encode your jql in the request.
In tools like Postman, you can directly use "jql=issuekey=GIV-177031" and it encodes the url itself. However, when the programming is on the table; we generally use CURL standards; which actually stands for:
"jql=issuekey%3DGIV-177031"
So, can you please try to send the request to the following URL:
url = "https://jciproducts.atlassian.net/rest/api/3/search/jql?jql=issuekey%3DGIV-177031&fields=*all"
Thank you for your suggest Salih Tuc -- unfortunately it returns the same results.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Chris DeNardis ,
Another thing that comes to my mind, you said you changed the API token. Did you choose any scope for the token? Can you try to get new token with general scope / all scopes?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Salih Tuc -- yes, I just tried changing to Scopes Token with only Jira and all classic related items -- same results.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Chris DeNardis ,
Welcome to the community!!
It looks like your request is authenticating, but Jira is returning no visible matching issues rather than an error. In Jira Cloud, issue search only returns issues the authenticated user can actually browse, so if the new API token belongs to a different Atlassian account, or that account no longer has access to project GIV, you can get back:
{"issues":[],"isLast":true}
even though the issue key exists. Atlassian’s docs also confirm that Jira Cloud basic auth should use email address + API token in the Authorization: Basic ... header, and API tokens are tied to the Atlassian account that created them.
A few things I would check:
Make sure the token was generated for the same email account you are passing into Base64Encode.
Verify that this account still has permission to view issue GIV-177031 in Jira.
Print the HTTP status code as well as the response body. If auth is wrong, you would usually expect a 401, but if auth succeeds and the user cannot see the issue, an empty result set is possible. Atlassian’s search API returns issue matches for the authenticated user’s visible issues.
Your use of MSXML2.XMLHTTP60 is fine. The User-Agent header is not really the root issue here; the more likely problem is that the new token is valid, but it is not for an account with access to that issue.
I would also slightly simplify the test by calling the issue directly instead of using search, for example:
url = "https://jciproducts.atlassian.net/rest/api/3/issue/GIV-177031"
That makes it easier to tell whether the specific issue is accessible with the new credentials. Atlassian’s v3 REST API supports direct issue retrieval as well as issue search.
And I would add status output like this:
Debug.Print xhr.Status
Debug.Print xhr.ResponseText
the code structure looks basically okay; the most likely cause is that the new API token is tied to an account that does not have permission to see that issue/project.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Himanshu
I did get a 404 error saying issue does not exist. I do know the issue does exist as if I go into Jira and search for that Jira ID - it shows up.
When I use the results of the Basic + Base64Encode("MyEmail@domain.com:yourAPIToken") - in Postman - it returns the data
Using the same query you suggested.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Himanshu
You gave me some insight when I received a 404 error -- that something was wrong with account or token. While Postman worked, what I decided was to hard code in the Email:Token Token instead of using the Base64Encode and the query returned the proper JSON file to process. So I am going to have to dig into why the Base64encode did not generate the appropriate token.
I am up and running now
Thanks
Chris
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.