0

I am getting this error but my method looks perfectly fine to me

def http = new HTTPBuilder()

http.request(
   'https://textalytics-topics-extraction-11.p.mashape.com/topics-1.2?txt=ben',    
   Method.GET,
   ContentType.JSON
) { req ->
    headers."X-Mashape-Key" = "mashkey"

    response.success = { resp, reader ->
        assert resp.statusLine.statusCode == 200
        println "Got response: ${resp.statusLine}"
        println "Content-Type: ${resp.headers.'Content-Type'}"
        println reader.text
    }

    response.'404' = {
        println 'Not found'
    }
}

any ideas?

Opal
  • 81,889
  • 28
  • 189
  • 210
Sagarmichael
  • 1,624
  • 7
  • 24
  • 53

1 Answers1

0

Given that HTTP Not acceptable means:

406 Not Acceptable

The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.

Then perhaps their API is finicky and you need to specify that you want the response to be JSON using the Accept header, using something like Accept: application/json.

Doug Richardson
  • 10,483
  • 6
  • 51
  • 77