Json 未找到由导致的HttpResponseException消息null

Json 未找到由导致的HttpResponseException消息null,json,groovy,Json,Groovy,这是我的控制器 package course_management_collection import groovyx.net.http.HTTPBuilder class CourseController { def equellaService def search() { if (params.courseCodeQuery) { def clientId = '2191fc19-2084-46f0-ab8e-aef7a912f

这是我的控制器

package course_management_collection

import groovyx.net.http.HTTPBuilder

class CourseController {

    def equellaService
    def search() {
        if (params.courseCodeQuery) {
            def clientId = '2191fc19-2084-46f0-ab8e-aef7a912ff54'
            def clientSecret = '24f83161-09df-47a2-aa70-7929d96cd4a9'        
            def http = new HTTPBuilder('https://eqtst.uow.edu.au/uow/')        
            def accessToken = equellaService.getAccessToken(http, clientId, clientSecret)

            def itemInfo = equellaService.getItemInfo(http, accessToken, params.courseCodeQuery, "81895979-822f-41b6-9a61-4629216f727d" )
            // def itemInfo = equellaService.getItemInfo(http, accessToken, "a05bc842-8226-4773-a64a-f92d20bd9834", 1)
            // def course= equellaService.getCourse(http, accessToken, "81895979-822f-41b6-9a61-4629216f727d")
            return [courseCodeQuery: params.courseCodeQuery, itemInfo: itemInfo]
            // return [courseCodeQuery: params.courseCodeQuery, course: course]
        }
    }
}
我对EqualService.groovy进行了如下编辑:

    package course_management_collection

    import grails.transaction.Transactional
    import static groovyx.net.http.Method.GET
    import static groovyx.net.http.ContentType.JSON

    @Transactional
    class EquellaService {

        def getAccessToken(http, clientId, clientSecret) {
        def accessToken
        http.request(GET, JSON) {
                uri.path = 'oauth/access_token'
                uri.query = [grant_type: 'client_credentials', client_id: clientId, client_secret: clientSecret, redirect_uri: 'default']

                response.success = { resp, json ->
                    accessToken = json.access_token
                }
        }

        return accessToken
  }


def getItemInfo(http, accessToken, params.courseCodeQuery, collection) {
    def itemInfo

    http.request(GET, JSON) {
    uri.path = "api/search/${params.courseCodeQuery}/${collection}"
      uri.query = [info: 'all']
        headers.'X-Authorization' = "access_token=${accessToken}"

        response.success = { resp, json ->
        itemInfo = json
      }
      }

    return itemInfo

    }
}
答复如下:

URI
/
Class
groovyx.net.http.HttpResponseException
Message
null
Caused by
Not Found
Around line 30 of grails-app\services\course_management_collection\EquellaService.groovy
27:def getItemInfo(http, accessToken, params.courseCodeQuery, collection) {
28:def itemInfo
29:
30:http.request(GET, JSON) {
31:uri.path = "api/search/${params.courseCodeQuery}/${collection}"
32:  uri.query = [info: 'all']
33:    headers.'X-Authorization' = "access_token=${accessToken}"
Around line 18 of grails-app\controllers\course_management_collection\CourseController.groovy
15:            def http = new HTTPBuilder('https://eqtst.uow.edu.au/uow/')        
16:            def accessToken = equellaService.getAccessToken(http, clientId, clientSecret)
17:           
18:            def itemInfo = equellaService.getItemInfo(http, accessToken, params.courseCodeQuery, "81895979-822f-41b6-9a61-4629216f727d" )
19:           // def itemInfo = equellaService.getItemInfo(http, accessToken, "a05bc842-8226-4773-a64a-f92d20bd9834", 1)
20:           //def course= equellaService.getCourse(http, accessToken, "81895979-822f-41b6-9a61-4629216f727d")
21:            return [courseCodeQuery: params.courseCodeQuery, itemInfo: itemInfo]
Trace
    Line | Method
->> 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Caused by HttpResponseException: Not Found

因为没有名为“courseCodeQuery”的变量,所以有“params.courseCodeQuery”?

def itemInfo = equellaService.getItemInfo(http, accessToken, courseCodeQuery, "81895979-822f-41b6-9a61-4629216f727d" )
应该是

def itemInfo = equellaService.getItemInfo(http, accessToken, params.courseCodeQuery, "81895979-822f-41b6-9a61-4629216f727d" )

注意参数。

这些参数可能会有所帮助。当有人回答我的问题时,我该怎么办。当你问一个新问题时,写一个标题来概括具体的问题