1

このコードを使用して、URL groovy から JSON オブジェクトを取得しています。ブラウザで試してみると、非常にうまく機能しますが、httpbuider を使用してプログラムで試してみると、予期しないエラーが発生します: 403 : Forbidden(つまり、キーAPIですが、私はそれを入れました

誰かが何が問題なのか考えていますか?

私のコードは:

def getJson(Integer id){
def adress = new HTTPBuilder("https://api.XXXY.com")

          def path="/vls/v1/etudiants/${id}?b=my&apiKey=99990"
          //Get request
          adresseServeur.request(Method.GET, JSON) {

              uri.path = path

              headers.Accept = 'application/json'
              // success response handler
              response.success = { resp, json ->
                  retourJson = json
              }

              // failure response handler 
              response.failure = { resp ->
                  println "Unexpected error: ${resp.statusLine.statusCode} : ${resp.statusLine.reasonPhrase}"
              }
4

0 に答える 0