Sample Codes

This topic gives Job Zone API plugin code samples to get you start quickly.

Sample Code - Java

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "{\r\n  \"filedata\": \"{{base64data}}\",\r\n  \"filename\": \"{{filename}}\",\r\n  \"userkey\": \"{{userkey}}\",\r\n  \"version\": \"1.0.0\",\r\n  \"subuserid\": \"{{subuserid}}\",\r\n  \"jsondata\": \"\"\r\n}");
Request request = new Request.Builder()
  .url("https://{{baseurl}}/RChilliPlugin/rchilli/jobZone")
  .method("POST", body)
  .build();
Response response = client.newCall(request).execute();

Sample Code - Python

import http.client

conn = http.client.HTTPSConnection("{{baseurl}}")
payload = "{\r\n  \"filedata\": \"{{base64data}}\",\r\n  \"filename\": \"{{filename}}\",\r\n  \"userkey\": \"{{userkey}}\",\r\n  \"version\": \"1.0.0\",\r\n  \"subuserid\": \"{{subuserid}}\",\r\n  \"jsondata\": \"\"\r\n}"
headers = {}
conn.request("POST", "/RChilliPlugin/rchilli/jobZone", 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://{{baseurl}}/RChilliPlugin/rchilli/jobZone',
  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": "{{base64data}}",
  "filename": "{{filename}}",
  "userkey": "{{userkey}}",
  "version": "1.0.0",
  "subuserid": "{{subuserid}}",
  "jsondata": ""
}',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Sample Code - NodeJS

var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': '{{baseurl}}',
  'path': '/RChilliPlugin/rchilli/jobZone',
  'headers': {
  },
  '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 =  "{\r\n  \"filedata\": \"{{base64data}}\",\r\n  \"filename\": \"{{filename}}\",\r\n  \"userkey\": \"{{userkey}}\",\r\n  \"version\": \"1.0.0\",\r\n  \"subuserid\": \"{{subuserid}}\",\r\n  \"jsondata\": \"\"\r\n}";

req.write(postData);

req.end();

Sample Code - Ruby

require "uri"
require "net/http"

url = URI("https://{{baseurl}}/RChilliPlugin/rchilli/jobZone")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request.body = "{\r\n  \"filedata\": \"{{base64data}}\",\r\n  \"filename\": \"{{filename}}\",\r\n  \"userkey\": \"{{userkey}}\",\r\n  \"version\": \"1.0.0\",\r\n  \"subuserid\": \"{{subuserid}}\",\r\n  \"jsondata\": \"\"\r\n}"

response = https.request(request)
puts response.read_body

Sample Code - C#

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://{{baseurl}}/RChilliPlugin/rchilli/jobZone");
var content = new StringContent("{\r\n  \"filedata\": \"{{base64data}}\",\r\n  \"filename\": \"{{filename}}\",\r\n  \"userkey\": \"{{userkey}}\",\r\n  \"version\": \"1.0.0\",\r\n  \"subuserid\": \"{{subuserid}}\",\r\n  \"jsondata\": \"\"\r\n}", null, "text/plain");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Sample Code - cURL

curl --location -g 'https://{{baseurl}}/RChilliPlugin/rchilli/jobZone' \
--data '{
  "filedata": "{{base64data}}",
  "filename": "{{filename}}",
  "userkey": "{{userkey}}",
  "version": "1.0.0",
  "subuserid": "{{subuserid}}",
  "jsondata": ""
}'