Sample Codes
This topic gives document converter code samples to get you start quickly.
Sample Code - Java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{
\"filedata\": \"File data in base64\",
\"filename\": \"File name with extension\",
\"userkey\": \"Your API UserKey\",
\"version\": \"1.0.0\",
\"subuserid\": \"Your Company Name\",
\"configuration\":[
{
\"outputtype\":\"Extension of File (docx,pdf, etc.)\",
\"facedetection\":\"true or false as per requirement\"
}]
}");
Request request = new Request.Builder()
.url("https://plugin.rchilli.com/RChilliPlugin/rchilli/documentConversion")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Sample Code - Python
import http.client
import json
conn = http.client.HTTPSConnection("plugin.rchilli.com")
payload = json.dumps({
"filedata": "File data in base64",
"filename": "File name with extension",
"userkey": "Your API UserKey",
"version": "1.0.0",
"subuserid": "Your Company Name",
"configuration":[
{
"outputtype":"Extension of File (docx,pdf, etc.)",
"facedetection":"true or false as per requirement"
}]
}
)
headers = {
'Content-Type': 'application/json'
}
conn.request("POST", "/RChilliPlugin/rchilli/documentConversion", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Sample Code - PHP
<?php>
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://plugin.rchilli.com/RChilliPlugin/rchilli/documentConversion',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"filedata": "File data in base64",
"filename": "File name with extension",
"userkey": "Your API UserKey",
"version": "1.0.0",
"subuserid": "Your Company Name",
"configuration":[
{
"outputtype":"Extension of File (docx,pdf, etc.)",
"facedetection":"true or false as per requirement"
}]
}
',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;cho 'Error: ' . $e->getMessage();
}
Sample Code - NodeJS
var https = require('follow-redirects').https;
var fs = require('fs');
var options = {
'method': 'POST',
'hostname': 'plugin.rchilli.com',
'path': '/RChilliPlugin/rchilli/documentConversion',
'headers': {
'Content-Type': 'application/json'
},
'maxRedirects': 20
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = JSON.stringify({
"filedata": "File data in base64",
"filename": "File name with extension",
"userkey": "Your API UserKey",
"version": "1.0.0",
"subuserid": "Your Company Name",
"configuration":[
{
"outputtype":"Extension of File (docx,pdf, etc.)",
"facedetection":"true or false as per requirement"
}]
});
req.write(postData);
req.end();
Sample Code - Ruby
require "uri"
require "json"
require "net/http"
url = URI("https://plugin.rchilli.com/RChilliPlugin/rchilli/documentConversion")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"filedata": "File data in base64",
"filename": "File name with extension",
"userkey": "Your API UserKey",
"version": "1.0.0",
"subuserid": "Your Company Name",
"configuration":[
{
"outputtype":"Extension of File (docx,pdf, etc.)",
"facedetection":"true or false as per requirement"
}]
})
response = https.request(request)
puts response.read_body
Sample Code - C#
var client = new RestClient("https://plugin.rchilli.com/RChilliPlugin/rchilli/documentConversion");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
var body = @"{""filedata"": ""File data in base64"",
""filename"": ""File name with extension"",
""userkey"": ""Your API UserKey"",
""version"": ""1.0.0"",
""subuserid"": ""Your Company Name"",
""configuration"":[
{
""outputtype"":""Extension of File (docx,pdf, etc.)"",
""facedetection"":""true or false as per requirement""
}]
}
" + "\n" +
@"";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample Code - cURL
curl --location --request POST 'https://plugin.rchilli.com/RChilliPlugin/rchilli/documentConversion' \
--header 'Content-Type: application/json' \
--data-raw '{
"filedata": "File data in base64",
"filename": "File name with extension",
"userkey": "Your API UserKey",
"version": "1.0.0",
"subuserid": "Your Company Name",
"configuration":[
{
"outputtype":"Extension of File (docx,pdf, etc.)",
"facedetection":"true or false as per requirement"
}]
}'