Question

This might be a noob question but i've been fiddling with it for hours now and wasn't able to find the solution.

I would like to send a POST request with form data using grails,
in jQuery this following 1 liner works as I wish:

$.post('<SOME SERVER URI>', {param1: 'p1'}, function(data) {console.log(data);})

but the following Grails code doesn't:

import static groovyx.net.http.ContentType.JSON  
import static groovyx.net.http.Method.POST  
import groovyx.net.http.HTTPBuilder  
...  
def http = new HTTPBuilder(<SERVER BASE URI>)
http.request(POST, JSON) {  
    uri.path = <REST OF URI>  
    uri.query = [param1: 'p1']  
    response.success = { resp, json ->    
        println 'success'  
    }  
}  

I think it has something to do with the data being sent, as the request leaves but fails (facebook graph is the base uri...)
the jquery code sends the data as form data, but i'm not sure thats the problem

Thanks!

Was it helpful?

Solution

It seems that facebook are really stickt on the params, and by sending 2 extra params facebook would not process the request, and simply return 400. Thanks so much!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top