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

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.
October 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

Suggest an answer

Log in or Sign up to answer
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.
October 26, 2022

was due to caching in script runner

TAGS
AUG Leaders

Atlassian Community Events