DELETE Application – Client examples

/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Delete Application client demonstrates deleting an application using 'request' node module.
 */
var request = require('request');
  
var bdCustomerApiKey = "6ab02370-97c4-11e4-b3f3-00155d53317c"; //This key is generated by Bluedot Point Access UI when your account is created
var bdApplicationId = "29d0571f-cfb3-459f-a346-6e11a351ad31"; //This ID of the application being deleted and can be retrieved through the GET Applications call
  
var options = {
    uri: "https://api.bluedotinnovation.com/1/applications?customerApiKey=" + bdCustomerApiKey+ "&applicationId=" + bdApplicationId,
    method: "DELETE"
};
  
request ( options,
    function (error, response, body) {
        if (error) {
            console.log(error);
        }
        console.log(JSON.stringify(response.body));
    }
);
package com.bluedotinnovation.application;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import com.bluedotinnovation.common.BDCommon;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Delete Application client demonstrates deleting an application using Apache HTTP client libraries
 */
public class DeleteApplication extends BDCommon {
     
    public static void main(String[] args) throws ParseException, IOException, KeyManagementException, NoSuchAlgorithmException {
         
        String bdCustomerApiKey = "7cd1ea80-d40e-11e4-84cb-b8ca3a6b879d"; //This key is generated by Bluedot Point Access UI when your account is created
        String bdApplicationId  = "7acadbf2-4424-4d3b-b4ec-98fad0a6618b"; //This ID of the application being deleted and can be retrieved through the GET Applications call
        String bdRestUrl        = "https://api.bluedotinnovation.com/1/applications?customerApiKey="+bdCustomerApiKey+"&applicationId=" + bdApplicationId;
         
        CloseableHttpClient httpRestClient = HttpClients.custom().setSSLSocketFactory(getSSLContextFactory()).build();
        HttpDelete request    = new HttpDelete(bdRestUrl);
        HttpResponse response = httpRestClient.execute(request);
        JSONParser parser     = new JSONParser();
        if (response.getStatusLine().getStatusCode() == 200) {
            System.out.println("Application has been deleted successfully");
            InputStream inputStream = response.getEntity().getContent();
            byte[] bytes            = readStream(inputStream);
            String resultString     = new String(bytes); //json result
            JSONObject jsonResult   = (JSONObject)  parser.parse(resultString);
            System.out.println(jsonResult);
        } else {
            InputStream inputStream = response.getEntity().getContent();
            byte[] bytes            = readStream(inputStream);
            String resultString     = new String(bytes); //json error result
            System.out.println(resultString);
        }
    }
}
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Net;
using System.Web.Script.Serialization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
/**
* @author Bluedot Innovation
* Copyright (c) 2016 Bluedot Innovation. All rights reserved.
* Delete Application client demonstrates deleting an application using the application id provided, through http web api library
*/
namespace BluedotPublicApiClient.applicationclient
{
    class DeleteApplication
    {
        public void delete()
        {
            String bdCustomerApiKey = "835d9460-7b91-11e4-bcb7-a0481cdc3311"; //This key is generated by Bluedot Point Access UI when your account is created
            String bdApplicationId  = "d66d4f5d-7c09-4bd1-8549-48893f121"; //This ID of the application being deleted and can be retrieved through the GET Applications call
            String bdRestBaseUrl    = "https://api.bluedotinnovation.com/1/applications?";
            String bdRestUrl = bdRestBaseUrl + "customerApiKey=" + bdCustomerApiKey + "&applicationId=" + bdApplicationId;
             
            WebRequestHandler handler = new WebRequestHandler();
            X509Certificate2 certificate = new X509Certificate2();
            handler.ClientCertificates.Add(certificate);
            HttpClient httpRestClient = new HttpClient(handler);
            //specify to use TLS 1.2 as default connection
            System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
            HttpResponseMessage serverResponse = httpRestClient.DeleteAsync(new Uri(bdRestUrl)).Result;
            if (serverResponse.IsSuccessStatusCode)
            {
                var result = serverResponse.Content.ReadAsStringAsync().Result;
                Console.WriteLine("{0}", result);
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)serverResponse.StatusCode, serverResponse.Content.ReadAsStringAsync().Result);
            }
        }
    }
}
Created by Bluedot DevOps on March 5, 2018

Start the discussion