Deletes a file that has been uploaded to the services, as well as to delete any resulting files that were produced (such as in the case of a conversion). The method can be called with a POST Request to the following URL:
Additional parameters available are listed below.
A successful request will return the number of files that were deleted.
//This sample uses the Request NodeJs library.
const request = require('request');
var servicesUrl = "https://azure.leadtools.com/api/";
var RequestID = '00000000-0000-0000-0000-000000000000';
var deleteUrl = servicesUrl + 'DeleteRequest?id='+ RequestID;
request.post(getRequestOptions(deleteUrl), deleteCallback);
function deleteCallback(error, response, body){
if(!error && response.statusCode == 200){
console.log("File has been successfully marked to run");
}else{
console.log("Failed to Delete: " + response.statusCode);
console.log(body);
}
}
function getRequestOptions(url){
//Function to generate and return HTTP request options.
var requestOptions ={
url: url,
headers: {
'Content-Length' : 0
},
auth: {
user:"Enter Application ID",
password:"Enter Application Password"
}
};
return requestOptions;
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using Newtonsoft.Json.Linq;
namespace Azure_Code_Snippets.DocumentationSnippets
{
class CloudServices_DeleteRequest_Demo
{
private string hostedServicesUrl = "https://azure.leadtools.com/api/";
public async void DeleteRequest()
{
string deleteUrl = string.Format("DeleteRequest?id={0}", Guid.Empty);
var client = InitClient();
var result = await client.PostAsync(deleteUrl, null);
if (result.StatusCode == HttpStatusCode.OK)
{
//Unique ID returned by the services
string deletedFiles = await result.Content.ReadAsStringAsync();
Console.WriteLine("Returned Message: " + deletedFiles);
}
else
Console.WriteLine("Request failed with the following response: " + result.StatusCode);
}
private HttpClient InitClient()
{
string AppId = "Enter Application ID";
string Password = "Enter Application Password";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(hostedServicesUrl);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
string authData = string.Format("{0}:{1}", AppId, Password);
string authHeaderValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(authData));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authHeaderValue);
return client;
}
}
}
#This sample uses the requests python library.
import requests, sys, time
servicesUrl = 'https://azure.leadtools.com/api/';
requestID = '00000000-0000-0000-0000-000000000000';
#Your application ID.
appId = "Enter Application ID";
#Your application password.
password = "Enter Application Password";
deleteRequestUrl = '{}DeleteRequest?id={}'
formattedQueryUrl = deleteRequestUrl.format(servicesUrl, requestID)
while True : #Poll the services to determine if the request has finished processing
request = requests.post(formattedQueryUrl, auth=(appId, password))
if request.status_code != 202:
break
time.sleep(5)
print("File finished processing with return code: " + str(request.status_code) + "\n")
<?php
$servicesBaseUrl = "https://azure.leadtools.com/api/";
$requestID = '00000000-0000-0000-0000-000000000000';
$deleteUrl = "%sDeleteRequest?id=%s";
$deleteUrl = sprintf($deleteUrl, $servicesBaseUrl, $requestID);
$requestOptions = GeneratePostOptions($deleteUrl);
while(true){ //Poll the services to determine if the request has finished processing.
$request = curl_init();
curl_setopt_array($request, $requestOptions); //Set the request URL
if(!$results = curl_exec($request)){
if(curl_errno($request)){
echo "There was an error queueing the request \n\r";
echo curl_error($request);
curl_close($request);
return false;
}
}
$httpReponse = curl_getinfo($request, CURLINFO_HTTP_CODE);
curl_close($request);
if($httpReponse != 202){
break; //The file has finished processing
}
sleep(5); //If the file hasn't finished processing, we will wait 5 seconds before checking again.
}
echo "Delete return response: " . $httpReponse . "\n\r";
function GeneratePostOptions($url)
{
$appId = "Enter Application ID";
$password = "Enter Application Password";
$headers = array(
"Content-Length : 0"
);
$postOptions = array(
CURLOPT_POST => 1,
CURLOPT_URL => $url,
CURLOPT_FRESH_CONNECT => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_USERPWD => "$appId:$password",
CURLOPT_FORBID_REUSE => 1,
CURLOPT_HTTPHEADER => $headers
);
return $postOptions;
}
?>
use base 'HTTP::Message';
use LWP::UserAgent ();
my $servicesUrl = "https://azure.leadtools.com/api/";
my $requestID = '00000000-0000-0000-0000-000000000000';
my $appId = 'Enter Application ID';
my $password = 'Enter Application Password';
my $headers = HTTP::Headers->new(
Content_Length => 0
);
$headers->authorization_basic($appId, $password);
#The User Agent to be used when making requests
my $ua = LWP::UserAgent->new;
my $deleteUrl = $servicesUrl . 'DeleteRequest?id=' . $requestID;
while(true){
$request = HTTP::Request->new(POST => $deleteUrl, $headers);
$response = $ua->request($request);
if($response->code != 202){
last;
}
sleep(5);
}
print("File finished processing with return code: " . $response->code . "\n");