Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,553,378
Community Members
 
Community Events
184
Community Groups

Json response suddenly not working anymore from script runner and jira 9.0

serge calderara
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Oct 19, 2022
 Dear all,

We are using MS Graph api to collect AD user information. One of our method suddenly stop working when using our groovy script in script runner.

Actually when calling the Graph API url from POSTMAN directly for requesting user information we receive the following response

{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users",
"value": [
    {
        "businessPhones": [],
        "displayName": "Rhea Sam",
        "givenName": null,
        "jobTitle": null,
        "mail": "user@mydoamin.com",
        "mobilePhone": null,
        "officeLocation": null,
        "preferredLanguage": null,
        "surname": null,
        "userPrincipalName": "user@mydoamin.com#EXT#@rlxcom.onmicrosoft.com",
        "id": "05906321-ed38-4bfd-9c9e-02bfb7d32405"
    }
]

}

Until now our groovy script call for that same API was working well but then suddenly stop working .

Here is calling method code we are using

public String getGuestUserId(String AuthToken,String userEmail){

    String _userId
    def http = new HTTPBuilder("https://graph.microsoft.com/v1.0/users/?")

        http.request(GET) {

            requestContentType = ContentType.JSON
            //uri.query = [ $filter:"mail eq '$userEmail'"].toString()
            uri.query=[$filter:"mail eq '$userEmail'"]
           
            headers.'Authorization' = "Bearer " + AuthToken    

            response.success = { resp, json ->
                if (json.value){
                _userId=json.value[0].id    
                
                } 
                else
                _userId=-1 // user does not exist
                                    
            }

            // user ID not found : error 404
            response.'404' = { resp ->       
                _userId = 'Not Found'
            }

        }
        _userId
        
    } 

What is happening when executing this method now is that the json.value return an error saying : "No such property: value for class: java.lang.Object" and du to that jump to the else line and return _userId=-1

Note that if we try to return just the json.toString() then it return only

"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users",
"value": []

What is wrong and why json.value sundenly stop working ?

 

Note :
we are using Jira DC 9.0 and Script runner 6.57.0

Thanks for your help regards

1 answer

1 accepted

0 votes
Answer accepted
serge calderara
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Oct 26, 2022

was due to caching in script runner

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events