ocrapi
POST
Convert a photo of a document into text
{{baseUrl}}/ocr/photo/toText
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/photo/toText");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/photo/toText" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/photo/toText"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/photo/toText"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/photo/toText");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/photo/toText"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/photo/toText HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/photo/toText")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/photo/toText"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/photo/toText")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/photo/toText")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/photo/toText');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/photo/toText',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/photo/toText';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/photo/toText',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/photo/toText")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/photo/toText',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/photo/toText',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/photo/toText');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/photo/toText',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/photo/toText';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/photo/toText"]
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}}/ocr/photo/toText" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/photo/toText",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/photo/toText', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/photo/toText');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/photo/toText');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/photo/toText' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/photo/toText' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/photo/toText", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/photo/toText"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/photo/toText"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/photo/toText")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/photo/toText') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/photo/toText";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/photo/toText \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/photo/toText \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/photo/toText
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/photo/toText")! 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()
POST
Convert a photo of a document or receipt into words with location
{{baseUrl}}/ocr/photo/to/words-with-location
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/photo/to/words-with-location");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/photo/to/words-with-location" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/photo/to/words-with-location"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/photo/to/words-with-location"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/photo/to/words-with-location");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/photo/to/words-with-location"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/photo/to/words-with-location HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/photo/to/words-with-location")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/photo/to/words-with-location"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/photo/to/words-with-location")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/photo/to/words-with-location")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/photo/to/words-with-location');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/photo/to/words-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/photo/to/words-with-location';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/photo/to/words-with-location',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/photo/to/words-with-location")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/photo/to/words-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/photo/to/words-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/photo/to/words-with-location');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/photo/to/words-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/photo/to/words-with-location';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/photo/to/words-with-location"]
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}}/ocr/photo/to/words-with-location" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/photo/to/words-with-location",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/photo/to/words-with-location', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/photo/to/words-with-location');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/photo/to/words-with-location');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/photo/to/words-with-location' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/photo/to/words-with-location' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/photo/to/words-with-location", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/photo/to/words-with-location"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/photo/to/words-with-location"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/photo/to/words-with-location")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/photo/to/words-with-location') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/photo/to/words-with-location";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/photo/to/words-with-location \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/photo/to/words-with-location \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/photo/to/words-with-location
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/photo/to/words-with-location")! 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()
POST
Convert a scanned image into text
{{baseUrl}}/ocr/image/toText
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/image/toText");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/image/toText" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/image/toText"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/image/toText"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/image/toText");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/image/toText"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/image/toText HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/image/toText")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/image/toText"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/image/toText")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/image/toText")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/image/toText');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/image/toText',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/image/toText';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/image/toText',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/image/toText")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/image/toText',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/image/toText',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/image/toText');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/image/toText',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/image/toText';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/image/toText"]
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}}/ocr/image/toText" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/image/toText",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/image/toText', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/image/toText');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/image/toText');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/image/toText' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/image/toText' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/image/toText", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/image/toText"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/image/toText"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/image/toText")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/image/toText') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/image/toText";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/image/toText \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/image/toText \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/image/toText
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/image/toText")! 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()
POST
Convert a scanned image into words with location (POST)
{{baseUrl}}/ocr/image/to/words-with-location
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/image/to/words-with-location");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/image/to/words-with-location" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/image/to/words-with-location"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/image/to/words-with-location"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/image/to/words-with-location");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/image/to/words-with-location"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/image/to/words-with-location HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/image/to/words-with-location")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/image/to/words-with-location"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/image/to/words-with-location")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/image/to/words-with-location")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/image/to/words-with-location');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/image/to/words-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/image/to/words-with-location';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/image/to/words-with-location',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/image/to/words-with-location")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/image/to/words-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/image/to/words-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/image/to/words-with-location');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/image/to/words-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/image/to/words-with-location';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/image/to/words-with-location"]
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}}/ocr/image/to/words-with-location" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/image/to/words-with-location",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/image/to/words-with-location', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/image/to/words-with-location');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/image/to/words-with-location');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/image/to/words-with-location' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/image/to/words-with-location' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/image/to/words-with-location", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/image/to/words-with-location"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/image/to/words-with-location"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/image/to/words-with-location")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/image/to/words-with-location') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/image/to/words-with-location";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/image/to/words-with-location \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/image/to/words-with-location \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/image/to/words-with-location
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/image/to/words-with-location")! 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()
POST
Convert a scanned image into words with location
{{baseUrl}}/ocr/image/to/lines-with-location
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/image/to/lines-with-location");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/image/to/lines-with-location" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/image/to/lines-with-location"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/image/to/lines-with-location"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/image/to/lines-with-location");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/image/to/lines-with-location"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/image/to/lines-with-location HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/image/to/lines-with-location")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/image/to/lines-with-location"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/image/to/lines-with-location")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/image/to/lines-with-location")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/image/to/lines-with-location');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/image/to/lines-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/image/to/lines-with-location';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/image/to/lines-with-location',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/image/to/lines-with-location")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/image/to/lines-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/image/to/lines-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/image/to/lines-with-location');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/image/to/lines-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/image/to/lines-with-location';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/image/to/lines-with-location"]
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}}/ocr/image/to/lines-with-location" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/image/to/lines-with-location",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/image/to/lines-with-location', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/image/to/lines-with-location');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/image/to/lines-with-location');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/image/to/lines-with-location' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/image/to/lines-with-location' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/image/to/lines-with-location", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/image/to/lines-with-location"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/image/to/lines-with-location"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/image/to/lines-with-location")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/image/to/lines-with-location') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/image/to/lines-with-location";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/image/to/lines-with-location \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/image/to/lines-with-location \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/image/to/lines-with-location
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/image/to/lines-with-location")! 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()
POST
Recognize a photo of a business card, extract key business information
{{baseUrl}}/ocr/photo/recognize/business-card
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/photo/recognize/business-card");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/photo/recognize/business-card" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/photo/recognize/business-card"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/photo/recognize/business-card"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/photo/recognize/business-card");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/photo/recognize/business-card"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/photo/recognize/business-card HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/photo/recognize/business-card")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/photo/recognize/business-card"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/photo/recognize/business-card")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/photo/recognize/business-card")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/photo/recognize/business-card');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/photo/recognize/business-card',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/photo/recognize/business-card';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/photo/recognize/business-card',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/photo/recognize/business-card")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/photo/recognize/business-card',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/photo/recognize/business-card',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/photo/recognize/business-card');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/photo/recognize/business-card',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/photo/recognize/business-card';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/photo/recognize/business-card"]
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}}/ocr/photo/recognize/business-card" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/photo/recognize/business-card",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/photo/recognize/business-card', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/photo/recognize/business-card');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/photo/recognize/business-card');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/photo/recognize/business-card' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/photo/recognize/business-card' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/photo/recognize/business-card", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/photo/recognize/business-card"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/photo/recognize/business-card"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/photo/recognize/business-card")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/photo/recognize/business-card') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/photo/recognize/business-card";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/photo/recognize/business-card \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/photo/recognize/business-card \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/photo/recognize/business-card
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/photo/recognize/business-card")! 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()
POST
Recognize a photo of a form, extract key fields and business information
{{baseUrl}}/ocr/photo/recognize/form
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/photo/recognize/form");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/photo/recognize/form" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/photo/recognize/form"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/photo/recognize/form"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/photo/recognize/form");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/photo/recognize/form"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/photo/recognize/form HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/photo/recognize/form")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/photo/recognize/form"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/photo/recognize/form")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/photo/recognize/form")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/photo/recognize/form');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/photo/recognize/form',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/photo/recognize/form';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/photo/recognize/form',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/photo/recognize/form")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/photo/recognize/form',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/photo/recognize/form',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/photo/recognize/form');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/photo/recognize/form',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/photo/recognize/form';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/photo/recognize/form"]
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}}/ocr/photo/recognize/form" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/photo/recognize/form",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/photo/recognize/form', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/photo/recognize/form');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/photo/recognize/form');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/photo/recognize/form' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/photo/recognize/form' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/photo/recognize/form", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/photo/recognize/form"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/photo/recognize/form"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/photo/recognize/form")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/photo/recognize/form') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/photo/recognize/form";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/photo/recognize/form \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/photo/recognize/form \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/photo/recognize/form
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/photo/recognize/form")! 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()
POST
Recognize a photo of a form, extract key fields using stored templates
{{baseUrl}}/ocr/photo/recognize/form/advanced
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/photo/recognize/form/advanced");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/photo/recognize/form/advanced" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/photo/recognize/form/advanced"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/photo/recognize/form/advanced"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/photo/recognize/form/advanced");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/photo/recognize/form/advanced"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/photo/recognize/form/advanced HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/photo/recognize/form/advanced")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/photo/recognize/form/advanced"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/photo/recognize/form/advanced")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/photo/recognize/form/advanced")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/photo/recognize/form/advanced');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/photo/recognize/form/advanced',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/photo/recognize/form/advanced';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/photo/recognize/form/advanced',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/photo/recognize/form/advanced")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/photo/recognize/form/advanced',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/photo/recognize/form/advanced',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/photo/recognize/form/advanced');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/photo/recognize/form/advanced',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/photo/recognize/form/advanced';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/photo/recognize/form/advanced"]
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}}/ocr/photo/recognize/form/advanced" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/photo/recognize/form/advanced",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/photo/recognize/form/advanced', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/photo/recognize/form/advanced');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/photo/recognize/form/advanced');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/photo/recognize/form/advanced' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/photo/recognize/form/advanced' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/photo/recognize/form/advanced", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/photo/recognize/form/advanced"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/photo/recognize/form/advanced"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/photo/recognize/form/advanced")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/photo/recognize/form/advanced') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/photo/recognize/form/advanced";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/photo/recognize/form/advanced \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/photo/recognize/form/advanced \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/photo/recognize/form/advanced
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/photo/recognize/form/advanced")! 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()
POST
Recognize a photo of a receipt, extract key business information
{{baseUrl}}/ocr/photo/recognize/receipt
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/photo/recognize/receipt");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/photo/recognize/receipt" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/photo/recognize/receipt"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/photo/recognize/receipt"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/photo/recognize/receipt");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/photo/recognize/receipt"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/photo/recognize/receipt HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/photo/recognize/receipt")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/photo/recognize/receipt"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/photo/recognize/receipt")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/photo/recognize/receipt")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/photo/recognize/receipt');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/photo/recognize/receipt',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/photo/recognize/receipt';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/photo/recognize/receipt',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/photo/recognize/receipt")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/photo/recognize/receipt',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/photo/recognize/receipt',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/photo/recognize/receipt');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/photo/recognize/receipt',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/photo/recognize/receipt';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/photo/recognize/receipt"]
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}}/ocr/photo/recognize/receipt" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/photo/recognize/receipt",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/photo/recognize/receipt', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/photo/recognize/receipt');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/photo/recognize/receipt');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/photo/recognize/receipt' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/photo/recognize/receipt' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/photo/recognize/receipt", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/photo/recognize/receipt"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/photo/recognize/receipt"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/photo/recognize/receipt")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/photo/recognize/receipt') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/photo/recognize/receipt";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/photo/recognize/receipt \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/photo/recognize/receipt \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/photo/recognize/receipt
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/photo/recognize/receipt")! 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()
POST
Convert a PDF into text lines with location
{{baseUrl}}/ocr/pdf/to/lines-with-location
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/pdf/to/lines-with-location");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/pdf/to/lines-with-location" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/pdf/to/lines-with-location"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/pdf/to/lines-with-location"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/pdf/to/lines-with-location");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/pdf/to/lines-with-location"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/pdf/to/lines-with-location HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/pdf/to/lines-with-location")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/pdf/to/lines-with-location"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/pdf/to/lines-with-location")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/pdf/to/lines-with-location")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/pdf/to/lines-with-location');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/pdf/to/lines-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/pdf/to/lines-with-location';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/pdf/to/lines-with-location',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/pdf/to/lines-with-location")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/pdf/to/lines-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/pdf/to/lines-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/pdf/to/lines-with-location');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/pdf/to/lines-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/pdf/to/lines-with-location';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/pdf/to/lines-with-location"]
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}}/ocr/pdf/to/lines-with-location" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/pdf/to/lines-with-location",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/pdf/to/lines-with-location', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/pdf/to/lines-with-location');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/pdf/to/lines-with-location');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/pdf/to/lines-with-location' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/pdf/to/lines-with-location' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/pdf/to/lines-with-location", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/pdf/to/lines-with-location"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/pdf/to/lines-with-location"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/pdf/to/lines-with-location")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/pdf/to/lines-with-location') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/pdf/to/lines-with-location";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/pdf/to/lines-with-location \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/pdf/to/lines-with-location \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/pdf/to/lines-with-location
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/pdf/to/lines-with-location")! 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()
POST
Convert a PDF into words with location
{{baseUrl}}/ocr/pdf/to/words-with-location
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/pdf/to/words-with-location");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/pdf/to/words-with-location" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/pdf/to/words-with-location"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/pdf/to/words-with-location"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/pdf/to/words-with-location");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/pdf/to/words-with-location"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/pdf/to/words-with-location HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/pdf/to/words-with-location")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/pdf/to/words-with-location"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/pdf/to/words-with-location")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/pdf/to/words-with-location")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/pdf/to/words-with-location');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/pdf/to/words-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/pdf/to/words-with-location';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/pdf/to/words-with-location',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/pdf/to/words-with-location")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/pdf/to/words-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/pdf/to/words-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/pdf/to/words-with-location');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/pdf/to/words-with-location',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/pdf/to/words-with-location';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/pdf/to/words-with-location"]
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}}/ocr/pdf/to/words-with-location" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/pdf/to/words-with-location",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/pdf/to/words-with-location', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/pdf/to/words-with-location');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/pdf/to/words-with-location');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/pdf/to/words-with-location' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/pdf/to/words-with-location' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/pdf/to/words-with-location", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/pdf/to/words-with-location"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/pdf/to/words-with-location"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/pdf/to/words-with-location")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/pdf/to/words-with-location') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/pdf/to/words-with-location";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/pdf/to/words-with-location \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/pdf/to/words-with-location \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/pdf/to/words-with-location
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/pdf/to/words-with-location")! 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()
POST
Converts an uploaded PDF file into text via Optical Character Recognition.
{{baseUrl}}/ocr/pdf/toText
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/pdf/toText");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/pdf/toText" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/pdf/toText"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/pdf/toText"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/pdf/toText");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/pdf/toText"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/pdf/toText HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/pdf/toText")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/pdf/toText"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/pdf/toText")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/pdf/toText")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/pdf/toText');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/pdf/toText',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/pdf/toText';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/pdf/toText',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/pdf/toText")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/pdf/toText',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/pdf/toText',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/pdf/toText');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/pdf/toText',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/pdf/toText';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/pdf/toText"]
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}}/ocr/pdf/toText" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/pdf/toText",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/pdf/toText', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/pdf/toText');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/pdf/toText');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/pdf/toText' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/pdf/toText' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/pdf/toText", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/pdf/toText"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/pdf/toText"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/pdf/toText")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/pdf/toText') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/pdf/toText";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/pdf/toText \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/pdf/toText \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/pdf/toText
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/pdf/toText")! 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()
POST
Convert an image of text into a binarized (light and dark) view
{{baseUrl}}/ocr/preprocessing/image/binarize
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/preprocessing/image/binarize");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/preprocessing/image/binarize" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/preprocessing/image/binarize"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/preprocessing/image/binarize"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/preprocessing/image/binarize");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/preprocessing/image/binarize"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/preprocessing/image/binarize HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/preprocessing/image/binarize")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/preprocessing/image/binarize"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/preprocessing/image/binarize")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/preprocessing/image/binarize")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/preprocessing/image/binarize');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/preprocessing/image/binarize',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/preprocessing/image/binarize';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/preprocessing/image/binarize',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/preprocessing/image/binarize")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/preprocessing/image/binarize',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/preprocessing/image/binarize',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/preprocessing/image/binarize');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/preprocessing/image/binarize',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/preprocessing/image/binarize';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/preprocessing/image/binarize"]
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}}/ocr/preprocessing/image/binarize" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/preprocessing/image/binarize",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/preprocessing/image/binarize', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/preprocessing/image/binarize');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/preprocessing/image/binarize');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/preprocessing/image/binarize' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/preprocessing/image/binarize' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/preprocessing/image/binarize", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/preprocessing/image/binarize"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/preprocessing/image/binarize"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/preprocessing/image/binarize")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/preprocessing/image/binarize') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/preprocessing/image/binarize";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/preprocessing/image/binarize \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/preprocessing/image/binarize \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/preprocessing/image/binarize
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/preprocessing/image/binarize")! 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()
POST
Convert an image of text into a binary (light and dark) view with ML
{{baseUrl}}/ocr/preprocessing/image/binarize/advanced
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/preprocessing/image/binarize/advanced");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/preprocessing/image/binarize/advanced" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/preprocessing/image/binarize/advanced"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/preprocessing/image/binarize/advanced"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/preprocessing/image/binarize/advanced");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/preprocessing/image/binarize/advanced"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/preprocessing/image/binarize/advanced HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/preprocessing/image/binarize/advanced")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/preprocessing/image/binarize/advanced"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/preprocessing/image/binarize/advanced")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/preprocessing/image/binarize/advanced")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/preprocessing/image/binarize/advanced');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/preprocessing/image/binarize/advanced',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/preprocessing/image/binarize/advanced';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/preprocessing/image/binarize/advanced',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/preprocessing/image/binarize/advanced")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/preprocessing/image/binarize/advanced',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/preprocessing/image/binarize/advanced',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/preprocessing/image/binarize/advanced');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/preprocessing/image/binarize/advanced',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/preprocessing/image/binarize/advanced';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/preprocessing/image/binarize/advanced"]
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}}/ocr/preprocessing/image/binarize/advanced" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/preprocessing/image/binarize/advanced",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/preprocessing/image/binarize/advanced', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/preprocessing/image/binarize/advanced');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/preprocessing/image/binarize/advanced');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/preprocessing/image/binarize/advanced' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/preprocessing/image/binarize/advanced' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/preprocessing/image/binarize/advanced", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/preprocessing/image/binarize/advanced"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/preprocessing/image/binarize/advanced"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/preprocessing/image/binarize/advanced")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/preprocessing/image/binarize/advanced') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/preprocessing/image/binarize/advanced";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/preprocessing/image/binarize/advanced \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/preprocessing/image/binarize/advanced \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/preprocessing/image/binarize/advanced
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/preprocessing/image/binarize/advanced")! 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()
POST
Detect and unrotate a document image (advanced)
{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/preprocessing/image/unrotate/advanced"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/preprocessing/image/unrotate/advanced HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/preprocessing/image/unrotate/advanced',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/preprocessing/image/unrotate/advanced',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced"]
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}}/ocr/preprocessing/image/unrotate/advanced" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/preprocessing/image/unrotate/advanced", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/preprocessing/image/unrotate/advanced') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/preprocessing/image/unrotate/advanced \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/preprocessing/image/unrotate/advanced \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/preprocessing/image/unrotate/advanced
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/preprocessing/image/unrotate/advanced")! 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()
POST
Detect and unrotate a document image
{{baseUrl}}/ocr/preprocessing/image/unrotate
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/preprocessing/image/unrotate");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/preprocessing/image/unrotate" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/preprocessing/image/unrotate"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/preprocessing/image/unrotate"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/preprocessing/image/unrotate");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/preprocessing/image/unrotate"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/preprocessing/image/unrotate HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/preprocessing/image/unrotate")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/preprocessing/image/unrotate"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/preprocessing/image/unrotate")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/preprocessing/image/unrotate")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/preprocessing/image/unrotate');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/preprocessing/image/unrotate',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/preprocessing/image/unrotate';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/preprocessing/image/unrotate',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/preprocessing/image/unrotate")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/preprocessing/image/unrotate',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/preprocessing/image/unrotate',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/preprocessing/image/unrotate');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/preprocessing/image/unrotate',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/preprocessing/image/unrotate';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/preprocessing/image/unrotate"]
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}}/ocr/preprocessing/image/unrotate" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/preprocessing/image/unrotate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/preprocessing/image/unrotate', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/preprocessing/image/unrotate');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/preprocessing/image/unrotate');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/preprocessing/image/unrotate' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/preprocessing/image/unrotate' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/preprocessing/image/unrotate", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/preprocessing/image/unrotate"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/preprocessing/image/unrotate"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/preprocessing/image/unrotate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/preprocessing/image/unrotate') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/preprocessing/image/unrotate";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/preprocessing/image/unrotate \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/preprocessing/image/unrotate \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/preprocessing/image/unrotate
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/preprocessing/image/unrotate")! 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()
POST
Detect and unskew a photo of a document
{{baseUrl}}/ocr/preprocessing/image/unskew
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/preprocessing/image/unskew");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/preprocessing/image/unskew" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/preprocessing/image/unskew"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/preprocessing/image/unskew"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/preprocessing/image/unskew");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/preprocessing/image/unskew"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/preprocessing/image/unskew HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/preprocessing/image/unskew")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/preprocessing/image/unskew"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/preprocessing/image/unskew")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/preprocessing/image/unskew")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/preprocessing/image/unskew');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/preprocessing/image/unskew',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/preprocessing/image/unskew';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/preprocessing/image/unskew',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/preprocessing/image/unskew")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/preprocessing/image/unskew',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/preprocessing/image/unskew',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/preprocessing/image/unskew');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/preprocessing/image/unskew',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/preprocessing/image/unskew';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/preprocessing/image/unskew"]
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}}/ocr/preprocessing/image/unskew" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/preprocessing/image/unskew",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/preprocessing/image/unskew', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/preprocessing/image/unskew');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/preprocessing/image/unskew');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/preprocessing/image/unskew' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/preprocessing/image/unskew' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/preprocessing/image/unskew", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/preprocessing/image/unskew"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/preprocessing/image/unskew"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/preprocessing/image/unskew")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/preprocessing/image/unskew') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/preprocessing/image/unskew";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/preprocessing/image/unskew \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/preprocessing/image/unskew \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/preprocessing/image/unskew
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/preprocessing/image/unskew")! 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()
POST
Get the angle of the page - document - receipt
{{baseUrl}}/ocr/preprocessing/image/get-page-angle
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/preprocessing/image/get-page-angle");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/preprocessing/image/get-page-angle" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/preprocessing/image/get-page-angle"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/preprocessing/image/get-page-angle"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/preprocessing/image/get-page-angle");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/preprocessing/image/get-page-angle"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/preprocessing/image/get-page-angle HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/preprocessing/image/get-page-angle")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/preprocessing/image/get-page-angle"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/preprocessing/image/get-page-angle")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/preprocessing/image/get-page-angle")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/preprocessing/image/get-page-angle');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/preprocessing/image/get-page-angle',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/preprocessing/image/get-page-angle';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/preprocessing/image/get-page-angle',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/preprocessing/image/get-page-angle")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/preprocessing/image/get-page-angle',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/preprocessing/image/get-page-angle',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/preprocessing/image/get-page-angle');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/preprocessing/image/get-page-angle',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/preprocessing/image/get-page-angle';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/preprocessing/image/get-page-angle"]
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}}/ocr/preprocessing/image/get-page-angle" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/preprocessing/image/get-page-angle",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/preprocessing/image/get-page-angle', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/preprocessing/image/get-page-angle');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/preprocessing/image/get-page-angle');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/preprocessing/image/get-page-angle' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/preprocessing/image/get-page-angle' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/preprocessing/image/get-page-angle", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/preprocessing/image/get-page-angle"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/preprocessing/image/get-page-angle"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/preprocessing/image/get-page-angle")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/preprocessing/image/get-page-angle') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/preprocessing/image/get-page-angle";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/preprocessing/image/get-page-angle \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/preprocessing/image/get-page-angle \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/preprocessing/image/get-page-angle
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/preprocessing/image/get-page-angle")! 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()
POST
Convert a photo of a receipt into a CSV file containing structured information from the receipt
{{baseUrl}}/ocr/receipts/photo/to/csv
HEADERS
Apikey
{{apiKey}}
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ocr/receipts/photo/to/csv");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "apikey: {{apiKey}}");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ocr/receipts/photo/to/csv" {:headers {:apikey "{{apiKey}}"}
:multipart [{:name "imageFile"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/ocr/receipts/photo/to/csv"
headers = HTTP::Headers{
"apikey" => "{{apiKey}}"
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\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}}/ocr/receipts/photo/to/csv"),
Headers =
{
{ "apikey", "{{apiKey}}" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "imageFile",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ocr/receipts/photo/to/csv");
var request = new RestRequest("", Method.Post);
request.AddHeader("apikey", "{{apiKey}}");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ocr/receipts/photo/to/csv"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "{{apiKey}}")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ocr/receipts/photo/to/csv HTTP/1.1
Apikey: {{apiKey}}
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 118
-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ocr/receipts/photo/to/csv")
.setHeader("apikey", "{{apiKey}}")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ocr/receipts/photo/to/csv"))
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/ocr/receipts/photo/to/csv")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ocr/receipts/photo/to/csv")
.header("apikey", "{{apiKey}}")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('imageFile', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ocr/receipts/photo/to/csv');
xhr.setRequestHeader('apikey', '{{apiKey}}');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('imageFile', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/receipts/photo/to/csv',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ocr/receipts/photo/to/csv';
const form = new FormData();
form.append('imageFile', '');
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('imageFile', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ocr/receipts/photo/to/csv',
method: 'POST',
headers: {
apikey: '{{apiKey}}'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/ocr/receipts/photo/to/csv")
.post(body)
.addHeader("apikey", "{{apiKey}}")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ocr/receipts/photo/to/csv',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
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('-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ocr/receipts/photo/to/csv',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {imageFile: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ocr/receipts/photo/to/csv');
req.headers({
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
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}}/ocr/receipts/photo/to/csv',
headers: {
apikey: '{{apiKey}}',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('imageFile', '');
const url = '{{baseUrl}}/ocr/receipts/photo/to/csv';
const options = {method: 'POST', headers: {apikey: '{{apiKey}}'}};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"apikey": @"{{apiKey}}",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"imageFile", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ocr/receipts/photo/to/csv"]
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}}/ocr/receipts/photo/to/csv" in
let headers = Header.add_list (Header.init ()) [
("apikey", "{{apiKey}}");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ocr/receipts/photo/to/csv",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"apikey: {{apiKey}}",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ocr/receipts/photo/to/csv', [
'headers' => [
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ocr/receipts/photo/to/csv');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'apikey' => '{{apiKey}}',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/ocr/receipts/photo/to/csv');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'apikey' => '{{apiKey}}'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ocr/receipts/photo/to/csv' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("apikey", "{{apiKey}}")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ocr/receipts/photo/to/csv' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'apikey': "{{apiKey}}",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/baseUrl/ocr/receipts/photo/to/csv", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ocr/receipts/photo/to/csv"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ocr/receipts/photo/to/csv"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('apikey' = '{{apiKey}}'), content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ocr/receipts/photo/to/csv")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '{{apiKey}}'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/ocr/receipts/photo/to/csv') do |req|
req.headers['apikey'] = '{{apiKey}}'
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"imageFile\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ocr/receipts/photo/to/csv";
let form = reqwest::multipart::Form::new()
.text("imageFile", "");
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("apikey", "{{apiKey}}".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ocr/receipts/photo/to/csv \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data' \
--form imageFile=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="imageFile"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/ocr/receipts/photo/to/csv \
apikey:'{{apiKey}}' \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'apikey: {{apiKey}}' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="imageFile"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/ocr/receipts/photo/to/csv
import Foundation
let headers = [
"apikey": "{{apiKey}}",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "imageFile",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ocr/receipts/photo/to/csv")! 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()