Sample Code
This topic gives JD parser code samples to get you start quickly.
Get more information on how you can quickly get started with RChilli APIs using Postman. This provides the technical information needed to access the RChilli services in flexible ways that will allow RChilli API to work seamlessly inside your application.
Sample Code - CSharp
JD API Sample Code CSharp 3.1, click download for the sample code.
var client = new RestClient("https://jdrest.rchilli.com/JDParser/RChilli/ParseJD");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n\t\"filedata\":\"{{base64data}}\",\n\t\"filename\":\"{{filename}}\",\n\t\"userkey\":\"{{userkey}}\",\n\t\"version\":\"3.1\",\n\t\"subuserid\":\"{{subuserid}}\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample Code - Java
JD API Sample Code Java 3.1, click download for the sample code.
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"filedata\":\"{{base64data}}\",\n\t\"filename\":\"{{filename}}\",\n\t\"userkey\":\"{{userkey}}\",\n\t\"version\":\"3.1\",\n\t\"subuserid\":\"{{subuserid}}\"\n}");
Request request = new Request.Builder()
.url("https://jdrest.rchilli.com/JDParser/RChilli/ParseJD")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Sample Code - NodeJs
JD API Sample Code NodeJs 3.1, click download for the sample code.
var https = require('follow-redirects').https;
var fs = require('fs');
var options = {
'method': 'POST',
'hostname': 'jdrest.rchilli.com',
'path': '/JDParser/RChilli/ParseJD',
'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": "{{base64data}}",
"filename": "{{filename}}",
"userkey": "{{userkey}}",
"version": "3.1",
"subuserid": "{{subuserid}}"
});
req.write(postData);
req.end();
Sample Code - PHP
JD API Sample Code PHP 3.1, click download for the sample code.
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://jdrest.rchilli.com/JDParser/RChilli/ParseJD');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Content-Type' => 'application/json'
));
$request->setBody('{\n "filedata":"{{base64data}}",\n "filename":"{{filename}}",\n "userkey":"{{userkey}}",\n "version":"3.1",\n "subuserid":"{{subuserid}}"\n}');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
Sample Code - Python
JD API Sample Code Python 3.1, click download for the sample code.
import http.client
import json
conn = http.client.HTTPSConnection("jdrest.rchilli.com")
payload = json.dumps({
"filedata": "{{base64data}}",
"filename": "{{filename}}",
"userkey": "{{userkey}}",
"version": "3.1",
"subuserid": "{{subuserid}}"
})
headers = {
'Content-Type': 'application/json'
}
conn.request("POST", "/JDParser/RChilli/ParseJD", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Sample Code - Ruby
JD API Sample Code Ruby 3.1, click download for the sample code.
require "uri"
require "net/http"
url = URI("https://jdrest.rchilli.com/JDParser/RChilli/ParseJD")
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 = "{\n\t\"filedata\":\"{{base64data}}\",\n\t\"filename\":\"{{filename}}\",\n\t\"userkey\":\"{{userkey}}\",\n\t\"version\":\"3.1\",\n\t\"subuserid\":\"{{subuserid}}\"\n}"
response = https.request(request)
puts response.read_body