HTTP Request Methods

  • REQUEST

The Cloud OCR API uses HTTP POST and HTTP GET methods for sending data to an HTTP server.  Query APIs support GET and POST. Update APIs support POST only.

  • URL

https://cloud.dynamsoft.com/rest/ocr/v1.1/{object_name}?{query_string}

  • Parameters
Parameter Type Description
object_name The object name, for example, quota, file
query_string The parameter passed in the HTTP header. The value has to be encoded with UrlEncode.

 

  • HTTP GET and POST Comparison
Request GET POST
URL https://cloud.dynamsoft.com/rest/ocr/v1.1/{object_name}?{query_string}
Request Parameters All values are passed through the query_string in HTTPS header. The values can be passed through the query_string, or in the HTTP Body.

  • The “method” parameter can be passed in the query_string or the HTTP Body;
  • The “x-api-key” and "range" parameters have to be passed in the HTTP Header;
  • All the values passed in query_string have to be encoded with UrlEncode;
  • The parameters passed in HTTP Body do not need to be encoded with UrlEncode.

Note: 

If the parameter is too long and cannot fit in an HTTP URL, it is recommended to pass the value in HTTP Body instead.

HTTP BODY No multipart/form-data
Note If a parameter is both specified in HTTP Body and query_string, the value in query_string takes place.

 

  • Sample Code of making a request
  1. GET request

Pass two parameter using HTTP GET: key1=value1 and key2=value2.

https://cloud.dynamsoft.com/rest/ocr/v1.1/file?key1=UrlEncode(value1)&key2=UrlEncode(value2)

  1. POST request

There are two ways to submit parameters in a POST request.

Method 1:

POST /rest/ocr/v1.1/file?key2=value2&key3=value3 HTTP/1.1User-Agent: curl/7.12.1 (x86_64-redhat-linux-gnu) libcurl/7.12.1 OpenSSL/0.9.7a zlib/1.2.1.2 libidn/0.5.6Pragma: no-cacheAccept: */*Host: cloud.dynamsoft.comContent-Length:123Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryS0JIa4uHF7yHd8xJ------WebKitFormBoundaryS0JIa4uHF7yHd8xJContent-Disposition: form-data; name="key1"value1------WebKitFormBoundaryS0JIa4uHF7yHd8xJ—
Method 2:

POST /rest/ocr/v1.1/file HTTP/1.1User-Agent: curl/7.12.1 (x86_64-redhat-linux-gnu) libcurl/7.12.1 OpenSSL/0.9.7a zlib/1.2.1.2 libidn/0.5.6Pragma: no-cacheAccept: */*Host: cloud.dynamsoft.comContent-Length:123Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryS0JIa4uHF7yHd8xJ------WebKitFormBoundaryS0JIa4uHF7yHd8xJContent-Disposition: form-data; name="key1" value1------WebKitFormBoundaryS0JIa4uHF7yHd8xJContent-Disposition: form-data; name="key2" value2------WebKitFormBoundaryS0JIa4uHF7yHd8xJContent-Disposition: form-data; name="key3" value3------WebKitFormBoundaryS0JIa4uHF7yHd8xJ--

 

 

Is this page helpful?