Created
September 3, 2016 08:06
-
-
Save chathurawidanage/4a361c4ee0c8233d66eea375c91dfedc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.http.HttpEntity; | |
import org.apache.http.HttpResponse; | |
import org.apache.http.client.HttpClient; | |
import org.apache.http.client.methods.HttpDelete; | |
import org.apache.http.client.methods.HttpGet; | |
import org.apache.http.impl.client.HttpClientBuilder; | |
import java.io.IOException; | |
import java.io.InputStream; | |
/** | |
* @author Chathura Widanage | |
*/ | |
public class TestDNMS { | |
public static void main(String[] args) throws IOException { | |
HttpClient httpClient= HttpClientBuilder.create().build(); | |
HttpDelete del=new HttpDelete("{Server}/api/trackedEntityInstances/pP5qtx4L5Pa"); | |
del.setHeader("Authorization","Basic {Auth}"); | |
HttpResponse delResponse = httpClient.execute(del); | |
try{ | |
HttpEntity entity = delResponse.getEntity(); | |
System.out.print("Entitiy : "); | |
System.out.println(entity); | |
InputStream content = entity.getContent(); | |
System.out.println(content); | |
}catch (NullPointerException nex){ | |
System.out.println("Null pointer Exception"); | |
} | |
int delStatusCode=delResponse.getStatusLine().getStatusCode(); | |
System.out.println(delStatusCode); | |
if(delStatusCode==204){ | |
System.out.println("tei deleted"); | |
}else{ | |
System.out.println("tei not deleted"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment