Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- curl -X DELETE https://my.firebase.io/users/bob.json?auth=my-secret
- def client = new RESTClient('https://my.firebase.io/users/bob.json?auth=my-secret')
- def response = client.delete(requestContentType: ContentType.ANY)
- def client = new RESTClient('https://my.firebase.io')
- def response = client.delete(
- requestContentType: ContentType.ANY,
- path: '/users/bob.json',
- query: [auth: 'my-secret']
- )
- def http = new HTTPBuilder('https://my.firebase.io')
- // perform a POST request, expecting TEXT response
- http.request(Method.DELETE, ContentType.ANY) {
- uri.path = '/users/bob.json'
- uri.query = [auth: 'my-secret']
- // response handler for a success response code
- response.success = { resp, reader ->
- println "response status: ${resp.statusLine}"
- }
- }
- def http = new HttpURLClient(url:'https://some/path/')
- resp = http.request(method:DELETE, contentType:JSON, path: "destroy/somewhere.json")
- def json = resp.data
- assert json.id != null
- assert resp.statusLine.statusCode == 200
- def createClient() {
- HttpParams params = new BasicHttpParams()
- HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1)
- HttpProtocolParams.setContentCharset(params, "UTF-8")
- params.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, true)
- SchemeRegistry registry = new SchemeRegistry()
- registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80))
- ClientConnectionManager ccm = new PoolingClientConnectionManager(registry)
- HttpConnectionParams.setConnectionTimeout(params, 8000)
- HttpConnectionParams.setSoTimeout(params, 5400000)
- HttpClient client = new DefaultHttpClient(ccm, params)
- return client
- }
- HttpClient client = createClient()
- def url = new URL("http", host, Integer.parseInt(port), "/dyn/admin/nucleus$component/")
- HttpDelete delete = new HttpDelete(url.toURI())
- // if you have any basic auth, you can plug it in here
- def auth="USER:PASS"
- delete.setHeader("Authorization", "Basic ${auth.getBytes().encodeBase64().toString()}")
- // convert a data map to NVPs
- def data = [:]
- List<NameValuePair> nvps = new ArrayList<NameValuePair>(data.size())
- data.each { name, value ->
- nvps.add(new BasicNameValuePair(name, value))
- }
- delete.setEntity(new UrlEncodedFormEntity(nvps))
- HttpResponse response = client.execute(delete)
- def status = response.statusLine.statusCode
- def content = response.entity.content
Add Comment
Please, Sign In to add comment