Status Error: HTTP/1.1 415 Unsupported Media Type
The first is what's used by default for the Accept header. You could
try manually using one of the other two variants by setting the header
in your request config closure:
headers.Accept = 'text/javascript'
Also if you haven't already, try turning on header and wire logging so
you can see the entire request and response as described here:
http://groovy.codehaus.org/modules/http-builder/doc/index.html#Logging_and_Debugging
-Tom
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
So it sounds like the server doesn't like the content-type header that
you're sending. I've seen several variants used to indicate a JSON
content-type:
application/json
application/javascript
text/javascript
The first is what's used by default for the Accept header. You could
try manually using one of the other two variants by setting the header
in your request config closure:
headers.Accept = 'text/javascript'
Also if you haven't already, try turning on header and wire logging so
you can see the entire request and response as described here:
http://groovy.codehaus.org/modules/http-builder/doc/index.html#Logging_and_Debugging
-Tom
Thanks
On Fri, Apr 9, 2010 at 4:36 PM, Chris Buckley <cnbu...@gmail.com> wrote:
> Hi everyone,
>
> Well I'm having a heck of a time posting JSON and receiving JSON could someone help me out here? (please...)
>
> Here's my code...
>
> def server = [
> server : [
> name : "olat",
> imageId : "3005755",
> flavorId : "4",
> metadata : [olat : "olat"]
> ]
> ]
>
> def http = new HTTPBuilder("${tokenAndPath[1]}/servers.json")
> http.request( POST, JSON ) { req ->
> headers.'X-Auth-Token' = tokenAndPath[0]
>
> send URLENC, server
>
> req.params.setBooleanParameter 'http.protocol.expect-continue', false
>
> response.success = { resp, json ->
> display.append "Status Success: ${resp.statusLine}\n"
> }
>
> response.failure = { resp, json ->
> display.append "Status Error: ${resp.statusLine}\n"
> }
>
> }
>
> What I'm getting back from the server is ...
>
> Status Error: HTTP/1.1 415 Unsupported Media Type
>
>