Api2Pdf - PDF Generation, Powered by AWS Lambda
POST
Convert URL to PDF (POST)
{{baseUrl}}/chrome/url
BODY json
{
"fileName": "",
"inlinePdf": false,
"options": {
"landscape": "",
"printBackground": false
},
"url": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/chrome/url");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n },\n \"url\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/chrome/url" {:content-type :json
:form-params {:fileName ""
:inlinePdf false
:options {:landscape ""
:printBackground false}
:url ""}})
require "http/client"
url = "{{baseUrl}}/chrome/url"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n },\n \"url\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/chrome/url"),
Content = new StringContent("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n },\n \"url\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/chrome/url");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n },\n \"url\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/chrome/url"
payload := strings.NewReader("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n },\n \"url\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/chrome/url HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 125
{
"fileName": "",
"inlinePdf": false,
"options": {
"landscape": "",
"printBackground": false
},
"url": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/chrome/url")
.setHeader("content-type", "application/json")
.setBody("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n },\n \"url\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/chrome/url"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n },\n \"url\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n },\n \"url\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/chrome/url")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/chrome/url")
.header("content-type", "application/json")
.body("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n },\n \"url\": \"\"\n}")
.asString();
const data = JSON.stringify({
fileName: '',
inlinePdf: false,
options: {
landscape: '',
printBackground: false
},
url: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/chrome/url');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/chrome/url',
headers: {'content-type': 'application/json'},
data: {
fileName: '',
inlinePdf: false,
options: {landscape: '', printBackground: false},
url: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/chrome/url';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"fileName":"","inlinePdf":false,"options":{"landscape":"","printBackground":false},"url":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/chrome/url',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "fileName": "",\n "inlinePdf": false,\n "options": {\n "landscape": "",\n "printBackground": false\n },\n "url": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n },\n \"url\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/chrome/url")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/chrome/url',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
fileName: '',
inlinePdf: false,
options: {landscape: '', printBackground: false},
url: ''
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/chrome/url',
headers: {'content-type': 'application/json'},
body: {
fileName: '',
inlinePdf: false,
options: {landscape: '', printBackground: false},
url: ''
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/chrome/url');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
fileName: '',
inlinePdf: false,
options: {
landscape: '',
printBackground: false
},
url: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/chrome/url',
headers: {'content-type': 'application/json'},
data: {
fileName: '',
inlinePdf: false,
options: {landscape: '', printBackground: false},
url: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/chrome/url';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"fileName":"","inlinePdf":false,"options":{"landscape":"","printBackground":false},"url":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"fileName": @"",
@"inlinePdf": @NO,
@"options": @{ @"landscape": @"", @"printBackground": @NO },
@"url": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/chrome/url"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/chrome/url" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n },\n \"url\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/chrome/url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'fileName' => '',
'inlinePdf' => null,
'options' => [
'landscape' => '',
'printBackground' => null
],
'url' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/chrome/url', [
'body' => '{
"fileName": "",
"inlinePdf": false,
"options": {
"landscape": "",
"printBackground": false
},
"url": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/chrome/url');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'fileName' => '',
'inlinePdf' => null,
'options' => [
'landscape' => '',
'printBackground' => null
],
'url' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'fileName' => '',
'inlinePdf' => null,
'options' => [
'landscape' => '',
'printBackground' => null
],
'url' => ''
]));
$request->setRequestUrl('{{baseUrl}}/chrome/url');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/chrome/url' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"fileName": "",
"inlinePdf": false,
"options": {
"landscape": "",
"printBackground": false
},
"url": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/chrome/url' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"fileName": "",
"inlinePdf": false,
"options": {
"landscape": "",
"printBackground": false
},
"url": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n },\n \"url\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/chrome/url", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/chrome/url"
payload = {
"fileName": "",
"inlinePdf": False,
"options": {
"landscape": "",
"printBackground": False
},
"url": ""
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/chrome/url"
payload <- "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n },\n \"url\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/chrome/url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n },\n \"url\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/chrome/url') do |req|
req.body = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n },\n \"url\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/chrome/url";
let payload = json!({
"fileName": "",
"inlinePdf": false,
"options": json!({
"landscape": "",
"printBackground": false
}),
"url": ""
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/chrome/url \
--header 'content-type: application/json' \
--data '{
"fileName": "",
"inlinePdf": false,
"options": {
"landscape": "",
"printBackground": false
},
"url": ""
}'
echo '{
"fileName": "",
"inlinePdf": false,
"options": {
"landscape": "",
"printBackground": false
},
"url": ""
}' | \
http POST {{baseUrl}}/chrome/url \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "fileName": "",\n "inlinePdf": false,\n "options": {\n "landscape": "",\n "printBackground": false\n },\n "url": ""\n}' \
--output-document \
- {{baseUrl}}/chrome/url
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"fileName": "",
"inlinePdf": false,
"options": [
"landscape": "",
"printBackground": false
],
"url": ""
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/chrome/url")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"cost": 0.0007979,
"mbIn": 0.06463,
"mbOut": 0.73327,
"pdf": "https://link-to-your-pdf",
"success": true
}
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"reason": "Source website could not be found",
"success": false
}
GET
Convert URL to PDF
{{baseUrl}}/chrome/url
QUERY PARAMS
url
apikey
{{apiKey}}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/chrome/url" {:query-params {:url ""
:apikey "{{apiKey}}"}})
require "http/client"
url = "{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D"
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'GET',
url: '{{baseUrl}}/chrome/url',
params: {url: '', apikey: '{{apiKey}}'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {
method: 'GET',
url: '{{baseUrl}}/chrome/url',
qs: {url: '', apikey: '{{apiKey}}'}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/chrome/url');
req.query({
url: '',
apikey: '{{apiKey}}'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'GET',
url: '{{baseUrl}}/chrome/url',
params: {url: '', apikey: '{{apiKey}}'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D');
echo $response->getBody();
setUrl('{{baseUrl}}/chrome/url');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData([
'url' => '',
'apikey' => '{{apiKey}}'
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/chrome/url');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString([
'url' => '',
'apikey' => '{{apiKey}}'
]));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/chrome/url"
querystring = {"url":"","apikey":"{{apiKey}}"}
response = requests.get(url, params=querystring)
print(response.json())
library(httr)
url <- "{{baseUrl}}/chrome/url"
queryString <- list(
url = "",
apikey = "{{apiKey}}"
)
response <- VERB("GET", url, query = queryString, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/chrome/url') do |req|
req.params['url'] = ''
req.params['apikey'] = '{{apiKey}}'
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/chrome/url";
let querystring = [
("url", ""),
("apikey", "{{apiKey}}"),
];
let client = reqwest::Client::new();
let response = client.get(url)
.query(&querystring)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url '{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D'
http GET '{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D'
wget --quiet \
--method GET \
--output-document \
- '{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D'
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/chrome/url?url=&apikey=%7B%7BapiKey%7D%7D")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"cost": 0.0007979,
"mbIn": 0.06463,
"mbOut": 0.73327,
"pdf": "https://link-to-your-pdf",
"success": true
}
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"reason": "Source website could not be found",
"success": false
}
POST
Convert raw HTML to PDF
{{baseUrl}}/chrome/html
BODY json
{
"fileName": "",
"html": "",
"inlinePdf": false,
"options": {
"landscape": "",
"printBackground": false
}
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/chrome/html");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n }\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/chrome/html" {:content-type :json
:form-params {:fileName ""
:html ""
:inlinePdf false
:options {:landscape ""
:printBackground false}}})
require "http/client"
url = "{{baseUrl}}/chrome/html"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n }\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/chrome/html"),
Content = new StringContent("{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n }\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/chrome/html");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n }\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/chrome/html"
payload := strings.NewReader("{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/chrome/html HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 126
{
"fileName": "",
"html": "",
"inlinePdf": false,
"options": {
"landscape": "",
"printBackground": false
}
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/chrome/html")
.setHeader("content-type", "application/json")
.setBody("{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n }\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/chrome/html"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n }\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n }\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/chrome/html")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/chrome/html")
.header("content-type", "application/json")
.body("{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n }\n}")
.asString();
const data = JSON.stringify({
fileName: '',
html: '',
inlinePdf: false,
options: {
landscape: '',
printBackground: false
}
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/chrome/html');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/chrome/html',
headers: {'content-type': 'application/json'},
data: {
fileName: '',
html: '',
inlinePdf: false,
options: {landscape: '', printBackground: false}
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/chrome/html';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"fileName":"","html":"","inlinePdf":false,"options":{"landscape":"","printBackground":false}}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/chrome/html',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "fileName": "",\n "html": "",\n "inlinePdf": false,\n "options": {\n "landscape": "",\n "printBackground": false\n }\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n }\n}")
val request = Request.Builder()
.url("{{baseUrl}}/chrome/html")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/chrome/html',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
fileName: '',
html: '',
inlinePdf: false,
options: {landscape: '', printBackground: false}
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/chrome/html',
headers: {'content-type': 'application/json'},
body: {
fileName: '',
html: '',
inlinePdf: false,
options: {landscape: '', printBackground: false}
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/chrome/html');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
fileName: '',
html: '',
inlinePdf: false,
options: {
landscape: '',
printBackground: false
}
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/chrome/html',
headers: {'content-type': 'application/json'},
data: {
fileName: '',
html: '',
inlinePdf: false,
options: {landscape: '', printBackground: false}
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/chrome/html';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"fileName":"","html":"","inlinePdf":false,"options":{"landscape":"","printBackground":false}}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"fileName": @"",
@"html": @"",
@"inlinePdf": @NO,
@"options": @{ @"landscape": @"", @"printBackground": @NO } };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/chrome/html"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/chrome/html" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n }\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/chrome/html",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'fileName' => '',
'html' => '',
'inlinePdf' => null,
'options' => [
'landscape' => '',
'printBackground' => null
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/chrome/html', [
'body' => '{
"fileName": "",
"html": "",
"inlinePdf": false,
"options": {
"landscape": "",
"printBackground": false
}
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/chrome/html');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'fileName' => '',
'html' => '',
'inlinePdf' => null,
'options' => [
'landscape' => '',
'printBackground' => null
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'fileName' => '',
'html' => '',
'inlinePdf' => null,
'options' => [
'landscape' => '',
'printBackground' => null
]
]));
$request->setRequestUrl('{{baseUrl}}/chrome/html');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/chrome/html' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"fileName": "",
"html": "",
"inlinePdf": false,
"options": {
"landscape": "",
"printBackground": false
}
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/chrome/html' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"fileName": "",
"html": "",
"inlinePdf": false,
"options": {
"landscape": "",
"printBackground": false
}
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n }\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/chrome/html", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/chrome/html"
payload = {
"fileName": "",
"html": "",
"inlinePdf": False,
"options": {
"landscape": "",
"printBackground": False
}
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/chrome/html"
payload <- "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n }\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/chrome/html")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n }\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/chrome/html') do |req|
req.body = "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"landscape\": \"\",\n \"printBackground\": false\n }\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/chrome/html";
let payload = json!({
"fileName": "",
"html": "",
"inlinePdf": false,
"options": json!({
"landscape": "",
"printBackground": false
})
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/chrome/html \
--header 'content-type: application/json' \
--data '{
"fileName": "",
"html": "",
"inlinePdf": false,
"options": {
"landscape": "",
"printBackground": false
}
}'
echo '{
"fileName": "",
"html": "",
"inlinePdf": false,
"options": {
"landscape": "",
"printBackground": false
}
}' | \
http POST {{baseUrl}}/chrome/html \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "fileName": "",\n "html": "",\n "inlinePdf": false,\n "options": {\n "landscape": "",\n "printBackground": false\n }\n}' \
--output-document \
- {{baseUrl}}/chrome/html
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"fileName": "",
"html": "",
"inlinePdf": false,
"options": [
"landscape": "",
"printBackground": false
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/chrome/html")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"cost": 0.0007979,
"mbIn": 0.06463,
"mbOut": 0.73327,
"pdf": "https://link-to-your-pdf",
"success": true
}
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"reason": "Source website could not be found",
"success": false
}
POST
Convert office document or image to PDF
{{baseUrl}}/libreoffice/convert
BODY json
{
"fileName": "",
"inlinePdf": false,
"url": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/libreoffice/convert");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"url\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/libreoffice/convert" {:content-type :json
:form-params {:fileName ""
:inlinePdf false
:url ""}})
require "http/client"
url = "{{baseUrl}}/libreoffice/convert"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"url\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/libreoffice/convert"),
Content = new StringContent("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"url\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/libreoffice/convert");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"url\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/libreoffice/convert"
payload := strings.NewReader("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"url\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/libreoffice/convert HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 55
{
"fileName": "",
"inlinePdf": false,
"url": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/libreoffice/convert")
.setHeader("content-type", "application/json")
.setBody("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"url\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/libreoffice/convert"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"url\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"url\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/libreoffice/convert")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/libreoffice/convert")
.header("content-type", "application/json")
.body("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"url\": \"\"\n}")
.asString();
const data = JSON.stringify({
fileName: '',
inlinePdf: false,
url: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/libreoffice/convert');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/libreoffice/convert',
headers: {'content-type': 'application/json'},
data: {fileName: '', inlinePdf: false, url: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/libreoffice/convert';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"fileName":"","inlinePdf":false,"url":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/libreoffice/convert',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "fileName": "",\n "inlinePdf": false,\n "url": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"url\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/libreoffice/convert")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/libreoffice/convert',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({fileName: '', inlinePdf: false, url: ''}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/libreoffice/convert',
headers: {'content-type': 'application/json'},
body: {fileName: '', inlinePdf: false, url: ''},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/libreoffice/convert');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
fileName: '',
inlinePdf: false,
url: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/libreoffice/convert',
headers: {'content-type': 'application/json'},
data: {fileName: '', inlinePdf: false, url: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/libreoffice/convert';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"fileName":"","inlinePdf":false,"url":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"fileName": @"",
@"inlinePdf": @NO,
@"url": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/libreoffice/convert"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/libreoffice/convert" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"url\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/libreoffice/convert",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'fileName' => '',
'inlinePdf' => null,
'url' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/libreoffice/convert', [
'body' => '{
"fileName": "",
"inlinePdf": false,
"url": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/libreoffice/convert');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'fileName' => '',
'inlinePdf' => null,
'url' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'fileName' => '',
'inlinePdf' => null,
'url' => ''
]));
$request->setRequestUrl('{{baseUrl}}/libreoffice/convert');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/libreoffice/convert' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"fileName": "",
"inlinePdf": false,
"url": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/libreoffice/convert' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"fileName": "",
"inlinePdf": false,
"url": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"url\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/libreoffice/convert", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/libreoffice/convert"
payload = {
"fileName": "",
"inlinePdf": False,
"url": ""
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/libreoffice/convert"
payload <- "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"url\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/libreoffice/convert")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"url\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/libreoffice/convert') do |req|
req.body = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"url\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/libreoffice/convert";
let payload = json!({
"fileName": "",
"inlinePdf": false,
"url": ""
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/libreoffice/convert \
--header 'content-type: application/json' \
--data '{
"fileName": "",
"inlinePdf": false,
"url": ""
}'
echo '{
"fileName": "",
"inlinePdf": false,
"url": ""
}' | \
http POST {{baseUrl}}/libreoffice/convert \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "fileName": "",\n "inlinePdf": false,\n "url": ""\n}' \
--output-document \
- {{baseUrl}}/libreoffice/convert
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"fileName": "",
"inlinePdf": false,
"url": ""
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/libreoffice/convert")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"cost": 0.0007979,
"mbIn": 0.06463,
"mbOut": 0.73327,
"pdf": "https://link-to-your-pdf",
"success": true
}
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"reason": "Source website could not be found",
"success": false
}
POST
Merge multiple PDFs together
{{baseUrl}}/merge
BODY json
{
"fileName": "",
"inlinePdf": false,
"urls": []
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/merge");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"urls\": []\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/merge" {:content-type :json
:form-params {:fileName ""
:inlinePdf false
:urls []}})
require "http/client"
url = "{{baseUrl}}/merge"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"urls\": []\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/merge"),
Content = new StringContent("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"urls\": []\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/merge");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"urls\": []\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/merge"
payload := strings.NewReader("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"urls\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/merge HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 56
{
"fileName": "",
"inlinePdf": false,
"urls": []
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/merge")
.setHeader("content-type", "application/json")
.setBody("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"urls\": []\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/merge"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"urls\": []\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"urls\": []\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/merge")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/merge")
.header("content-type", "application/json")
.body("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"urls\": []\n}")
.asString();
const data = JSON.stringify({
fileName: '',
inlinePdf: false,
urls: []
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/merge');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/merge',
headers: {'content-type': 'application/json'},
data: {fileName: '', inlinePdf: false, urls: []}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/merge';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"fileName":"","inlinePdf":false,"urls":[]}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/merge',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "fileName": "",\n "inlinePdf": false,\n "urls": []\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"urls\": []\n}")
val request = Request.Builder()
.url("{{baseUrl}}/merge")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/merge',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({fileName: '', inlinePdf: false, urls: []}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/merge',
headers: {'content-type': 'application/json'},
body: {fileName: '', inlinePdf: false, urls: []},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/merge');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
fileName: '',
inlinePdf: false,
urls: []
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/merge',
headers: {'content-type': 'application/json'},
data: {fileName: '', inlinePdf: false, urls: []}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/merge';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"fileName":"","inlinePdf":false,"urls":[]}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"fileName": @"",
@"inlinePdf": @NO,
@"urls": @[ ] };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/merge"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/merge" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"urls\": []\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/merge",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'fileName' => '',
'inlinePdf' => null,
'urls' => [
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/merge', [
'body' => '{
"fileName": "",
"inlinePdf": false,
"urls": []
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/merge');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'fileName' => '',
'inlinePdf' => null,
'urls' => [
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'fileName' => '',
'inlinePdf' => null,
'urls' => [
]
]));
$request->setRequestUrl('{{baseUrl}}/merge');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/merge' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"fileName": "",
"inlinePdf": false,
"urls": []
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/merge' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"fileName": "",
"inlinePdf": false,
"urls": []
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"urls\": []\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/merge", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/merge"
payload = {
"fileName": "",
"inlinePdf": False,
"urls": []
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/merge"
payload <- "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"urls\": []\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/merge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"urls\": []\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/merge') do |req|
req.body = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"urls\": []\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/merge";
let payload = json!({
"fileName": "",
"inlinePdf": false,
"urls": ()
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/merge \
--header 'content-type: application/json' \
--data '{
"fileName": "",
"inlinePdf": false,
"urls": []
}'
echo '{
"fileName": "",
"inlinePdf": false,
"urls": []
}' | \
http POST {{baseUrl}}/merge \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "fileName": "",\n "inlinePdf": false,\n "urls": []\n}' \
--output-document \
- {{baseUrl}}/merge
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"fileName": "",
"inlinePdf": false,
"urls": []
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/merge")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"cost": 0.0007979,
"mbIn": 0.06463,
"mbOut": 0.73327,
"pdf": "https://link-to-your-pdf",
"success": true
}
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"reason": "Source website could not be found",
"success": false
}
POST
Convert URL to PDF (1)
{{baseUrl}}/wkhtmltopdf/url
BODY json
{
"fileName": "",
"inlinePdf": false,
"options": {
"orientation": "",
"pageSize": ""
},
"url": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/wkhtmltopdf/url");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n },\n \"url\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/wkhtmltopdf/url" {:content-type :json
:form-params {:fileName ""
:inlinePdf false
:options {:orientation ""
:pageSize ""}
:url ""}})
require "http/client"
url = "{{baseUrl}}/wkhtmltopdf/url"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n },\n \"url\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/wkhtmltopdf/url"),
Content = new StringContent("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n },\n \"url\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/wkhtmltopdf/url");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n },\n \"url\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/wkhtmltopdf/url"
payload := strings.NewReader("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n },\n \"url\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/wkhtmltopdf/url HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 117
{
"fileName": "",
"inlinePdf": false,
"options": {
"orientation": "",
"pageSize": ""
},
"url": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/wkhtmltopdf/url")
.setHeader("content-type", "application/json")
.setBody("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n },\n \"url\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/wkhtmltopdf/url"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n },\n \"url\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n },\n \"url\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/wkhtmltopdf/url")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/wkhtmltopdf/url")
.header("content-type", "application/json")
.body("{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n },\n \"url\": \"\"\n}")
.asString();
const data = JSON.stringify({
fileName: '',
inlinePdf: false,
options: {
orientation: '',
pageSize: ''
},
url: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/wkhtmltopdf/url');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/wkhtmltopdf/url',
headers: {'content-type': 'application/json'},
data: {
fileName: '',
inlinePdf: false,
options: {orientation: '', pageSize: ''},
url: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/wkhtmltopdf/url';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"fileName":"","inlinePdf":false,"options":{"orientation":"","pageSize":""},"url":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/wkhtmltopdf/url',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "fileName": "",\n "inlinePdf": false,\n "options": {\n "orientation": "",\n "pageSize": ""\n },\n "url": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n },\n \"url\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/wkhtmltopdf/url")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/wkhtmltopdf/url',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
fileName: '',
inlinePdf: false,
options: {orientation: '', pageSize: ''},
url: ''
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/wkhtmltopdf/url',
headers: {'content-type': 'application/json'},
body: {
fileName: '',
inlinePdf: false,
options: {orientation: '', pageSize: ''},
url: ''
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/wkhtmltopdf/url');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
fileName: '',
inlinePdf: false,
options: {
orientation: '',
pageSize: ''
},
url: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/wkhtmltopdf/url',
headers: {'content-type': 'application/json'},
data: {
fileName: '',
inlinePdf: false,
options: {orientation: '', pageSize: ''},
url: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/wkhtmltopdf/url';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"fileName":"","inlinePdf":false,"options":{"orientation":"","pageSize":""},"url":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"fileName": @"",
@"inlinePdf": @NO,
@"options": @{ @"orientation": @"", @"pageSize": @"" },
@"url": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/wkhtmltopdf/url"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/wkhtmltopdf/url" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n },\n \"url\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/wkhtmltopdf/url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'fileName' => '',
'inlinePdf' => null,
'options' => [
'orientation' => '',
'pageSize' => ''
],
'url' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/wkhtmltopdf/url', [
'body' => '{
"fileName": "",
"inlinePdf": false,
"options": {
"orientation": "",
"pageSize": ""
},
"url": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/wkhtmltopdf/url');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'fileName' => '',
'inlinePdf' => null,
'options' => [
'orientation' => '',
'pageSize' => ''
],
'url' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'fileName' => '',
'inlinePdf' => null,
'options' => [
'orientation' => '',
'pageSize' => ''
],
'url' => ''
]));
$request->setRequestUrl('{{baseUrl}}/wkhtmltopdf/url');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/wkhtmltopdf/url' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"fileName": "",
"inlinePdf": false,
"options": {
"orientation": "",
"pageSize": ""
},
"url": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/wkhtmltopdf/url' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"fileName": "",
"inlinePdf": false,
"options": {
"orientation": "",
"pageSize": ""
},
"url": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n },\n \"url\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/wkhtmltopdf/url", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/wkhtmltopdf/url"
payload = {
"fileName": "",
"inlinePdf": False,
"options": {
"orientation": "",
"pageSize": ""
},
"url": ""
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/wkhtmltopdf/url"
payload <- "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n },\n \"url\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/wkhtmltopdf/url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n },\n \"url\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/wkhtmltopdf/url') do |req|
req.body = "{\n \"fileName\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n },\n \"url\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/wkhtmltopdf/url";
let payload = json!({
"fileName": "",
"inlinePdf": false,
"options": json!({
"orientation": "",
"pageSize": ""
}),
"url": ""
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/wkhtmltopdf/url \
--header 'content-type: application/json' \
--data '{
"fileName": "",
"inlinePdf": false,
"options": {
"orientation": "",
"pageSize": ""
},
"url": ""
}'
echo '{
"fileName": "",
"inlinePdf": false,
"options": {
"orientation": "",
"pageSize": ""
},
"url": ""
}' | \
http POST {{baseUrl}}/wkhtmltopdf/url \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "fileName": "",\n "inlinePdf": false,\n "options": {\n "orientation": "",\n "pageSize": ""\n },\n "url": ""\n}' \
--output-document \
- {{baseUrl}}/wkhtmltopdf/url
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"fileName": "",
"inlinePdf": false,
"options": [
"orientation": "",
"pageSize": ""
],
"url": ""
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/wkhtmltopdf/url")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"cost": 0.0007979,
"mbIn": 0.06463,
"mbOut": 0.73327,
"pdf": "https://link-to-your-pdf",
"success": true
}
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"reason": "Source website could not be found",
"success": false
}
GET
Convert URL to PDF (GET)
{{baseUrl}}/wkhtmltopdf/url
QUERY PARAMS
url
apikey
{{apiKey}}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/wkhtmltopdf/url" {:query-params {:url ""
:apikey "{{apiKey}}"}})
require "http/client"
url = "{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D"
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'GET',
url: '{{baseUrl}}/wkhtmltopdf/url',
params: {url: '', apikey: '{{apiKey}}'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {
method: 'GET',
url: '{{baseUrl}}/wkhtmltopdf/url',
qs: {url: '', apikey: '{{apiKey}}'}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/wkhtmltopdf/url');
req.query({
url: '',
apikey: '{{apiKey}}'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'GET',
url: '{{baseUrl}}/wkhtmltopdf/url',
params: {url: '', apikey: '{{apiKey}}'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D');
echo $response->getBody();
setUrl('{{baseUrl}}/wkhtmltopdf/url');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData([
'url' => '',
'apikey' => '{{apiKey}}'
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/wkhtmltopdf/url');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString([
'url' => '',
'apikey' => '{{apiKey}}'
]));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/wkhtmltopdf/url"
querystring = {"url":"","apikey":"{{apiKey}}"}
response = requests.get(url, params=querystring)
print(response.json())
library(httr)
url <- "{{baseUrl}}/wkhtmltopdf/url"
queryString <- list(
url = "",
apikey = "{{apiKey}}"
)
response <- VERB("GET", url, query = queryString, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/wkhtmltopdf/url') do |req|
req.params['url'] = ''
req.params['apikey'] = '{{apiKey}}'
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/wkhtmltopdf/url";
let querystring = [
("url", ""),
("apikey", "{{apiKey}}"),
];
let client = reqwest::Client::new();
let response = client.get(url)
.query(&querystring)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url '{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D'
http GET '{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D'
wget --quiet \
--method GET \
--output-document \
- '{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D'
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/wkhtmltopdf/url?url=&apikey=%7B%7BapiKey%7D%7D")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"cost": 0.0007979,
"mbIn": 0.06463,
"mbOut": 0.73327,
"pdf": "https://link-to-your-pdf",
"success": true
}
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"reason": "Source website could not be found",
"success": false
}
POST
Convert raw HTML to PDF (POST)
{{baseUrl}}/wkhtmltopdf/html
BODY json
{
"fileName": "",
"html": "",
"inlinePdf": false,
"options": {
"orientation": "",
"pageSize": ""
}
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/wkhtmltopdf/html");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n }\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/wkhtmltopdf/html" {:content-type :json
:form-params {:fileName ""
:html ""
:inlinePdf false
:options {:orientation ""
:pageSize ""}}})
require "http/client"
url = "{{baseUrl}}/wkhtmltopdf/html"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n }\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/wkhtmltopdf/html"),
Content = new StringContent("{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n }\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/wkhtmltopdf/html");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n }\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/wkhtmltopdf/html"
payload := strings.NewReader("{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/wkhtmltopdf/html HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 118
{
"fileName": "",
"html": "",
"inlinePdf": false,
"options": {
"orientation": "",
"pageSize": ""
}
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/wkhtmltopdf/html")
.setHeader("content-type", "application/json")
.setBody("{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n }\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/wkhtmltopdf/html"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n }\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n }\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/wkhtmltopdf/html")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/wkhtmltopdf/html")
.header("content-type", "application/json")
.body("{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n }\n}")
.asString();
const data = JSON.stringify({
fileName: '',
html: '',
inlinePdf: false,
options: {
orientation: '',
pageSize: ''
}
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/wkhtmltopdf/html');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/wkhtmltopdf/html',
headers: {'content-type': 'application/json'},
data: {
fileName: '',
html: '',
inlinePdf: false,
options: {orientation: '', pageSize: ''}
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/wkhtmltopdf/html';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"fileName":"","html":"","inlinePdf":false,"options":{"orientation":"","pageSize":""}}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/wkhtmltopdf/html',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "fileName": "",\n "html": "",\n "inlinePdf": false,\n "options": {\n "orientation": "",\n "pageSize": ""\n }\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n }\n}")
val request = Request.Builder()
.url("{{baseUrl}}/wkhtmltopdf/html")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/wkhtmltopdf/html',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
fileName: '',
html: '',
inlinePdf: false,
options: {orientation: '', pageSize: ''}
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/wkhtmltopdf/html',
headers: {'content-type': 'application/json'},
body: {
fileName: '',
html: '',
inlinePdf: false,
options: {orientation: '', pageSize: ''}
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/wkhtmltopdf/html');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
fileName: '',
html: '',
inlinePdf: false,
options: {
orientation: '',
pageSize: ''
}
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/wkhtmltopdf/html',
headers: {'content-type': 'application/json'},
data: {
fileName: '',
html: '',
inlinePdf: false,
options: {orientation: '', pageSize: ''}
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/wkhtmltopdf/html';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"fileName":"","html":"","inlinePdf":false,"options":{"orientation":"","pageSize":""}}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"fileName": @"",
@"html": @"",
@"inlinePdf": @NO,
@"options": @{ @"orientation": @"", @"pageSize": @"" } };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/wkhtmltopdf/html"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/wkhtmltopdf/html" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n }\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/wkhtmltopdf/html",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'fileName' => '',
'html' => '',
'inlinePdf' => null,
'options' => [
'orientation' => '',
'pageSize' => ''
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/wkhtmltopdf/html', [
'body' => '{
"fileName": "",
"html": "",
"inlinePdf": false,
"options": {
"orientation": "",
"pageSize": ""
}
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/wkhtmltopdf/html');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'fileName' => '',
'html' => '',
'inlinePdf' => null,
'options' => [
'orientation' => '',
'pageSize' => ''
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'fileName' => '',
'html' => '',
'inlinePdf' => null,
'options' => [
'orientation' => '',
'pageSize' => ''
]
]));
$request->setRequestUrl('{{baseUrl}}/wkhtmltopdf/html');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/wkhtmltopdf/html' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"fileName": "",
"html": "",
"inlinePdf": false,
"options": {
"orientation": "",
"pageSize": ""
}
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/wkhtmltopdf/html' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"fileName": "",
"html": "",
"inlinePdf": false,
"options": {
"orientation": "",
"pageSize": ""
}
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n }\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/wkhtmltopdf/html", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/wkhtmltopdf/html"
payload = {
"fileName": "",
"html": "",
"inlinePdf": False,
"options": {
"orientation": "",
"pageSize": ""
}
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/wkhtmltopdf/html"
payload <- "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n }\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/wkhtmltopdf/html")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n }\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/wkhtmltopdf/html') do |req|
req.body = "{\n \"fileName\": \"\",\n \"html\": \"\",\n \"inlinePdf\": false,\n \"options\": {\n \"orientation\": \"\",\n \"pageSize\": \"\"\n }\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/wkhtmltopdf/html";
let payload = json!({
"fileName": "",
"html": "",
"inlinePdf": false,
"options": json!({
"orientation": "",
"pageSize": ""
})
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/wkhtmltopdf/html \
--header 'content-type: application/json' \
--data '{
"fileName": "",
"html": "",
"inlinePdf": false,
"options": {
"orientation": "",
"pageSize": ""
}
}'
echo '{
"fileName": "",
"html": "",
"inlinePdf": false,
"options": {
"orientation": "",
"pageSize": ""
}
}' | \
http POST {{baseUrl}}/wkhtmltopdf/html \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "fileName": "",\n "html": "",\n "inlinePdf": false,\n "options": {\n "orientation": "",\n "pageSize": ""\n }\n}' \
--output-document \
- {{baseUrl}}/wkhtmltopdf/html
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"fileName": "",
"html": "",
"inlinePdf": false,
"options": [
"orientation": "",
"pageSize": ""
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/wkhtmltopdf/html")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"cost": 0.0007979,
"mbIn": 0.06463,
"mbOut": 0.73327,
"pdf": "https://link-to-your-pdf",
"success": true
}
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"reason": "Source website could not be found",
"success": false
}
GET
Generate bar codes and QR codes with ZXING.
{{baseUrl}}/zebra
QUERY PARAMS
format
value
apikey
{{apiKey}}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/zebra" {:query-params {:format ""
:value ""
:apikey "{{apiKey}}"}})
require "http/client"
url = "{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D"
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'GET',
url: '{{baseUrl}}/zebra',
params: {format: '', value: '', apikey: '{{apiKey}}'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {
method: 'GET',
url: '{{baseUrl}}/zebra',
qs: {format: '', value: '', apikey: '{{apiKey}}'}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/zebra');
req.query({
format: '',
value: '',
apikey: '{{apiKey}}'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'GET',
url: '{{baseUrl}}/zebra',
params: {format: '', value: '', apikey: '{{apiKey}}'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D');
echo $response->getBody();
setUrl('{{baseUrl}}/zebra');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData([
'format' => '',
'value' => '',
'apikey' => '{{apiKey}}'
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/zebra');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString([
'format' => '',
'value' => '',
'apikey' => '{{apiKey}}'
]));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/zebra"
querystring = {"format":"","value":"","apikey":"{{apiKey}}"}
response = requests.get(url, params=querystring)
print(response.json())
library(httr)
url <- "{{baseUrl}}/zebra"
queryString <- list(
format = "",
value = "",
apikey = "{{apiKey}}"
)
response <- VERB("GET", url, query = queryString, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/zebra') do |req|
req.params['format'] = ''
req.params['value'] = ''
req.params['apikey'] = '{{apiKey}}'
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/zebra";
let querystring = [
("format", ""),
("value", ""),
("apikey", "{{apiKey}}"),
];
let client = reqwest::Client::new();
let response = client.get(url)
.query(&querystring)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url '{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D'
http GET '{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D'
wget --quiet \
--method GET \
--output-document \
- '{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D'
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/zebra?format=&value=&apikey=%7B%7BapiKey%7D%7D")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()