community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

Help connecting to a REST API with Alteryx

Meteoroid
Hello,

I'm trying to contact an API to perform Optical Character Recognition (OCR) on a batch of images, using the API service below:
 
 
Because this API performs a process on a file (or batch of files), the protocol seems different to other APIs I've used to fetch data.
 
The example API call constitutes a set of instructions to perform on the file - with a base url and some parameters on the end (see below).
 
...However, I can't see anything in API guide about how I can instruct the API to point to files to perform this operation on.
 
They provide some sample code for cs Download .NET, as well as for JAVA and PHP (not really sure what this means though) (http://www.ocrwebservice.com/sample/SampleOCRRESTProjectCSharp.zip)
 
Does anyone have an idea how I can tell Alteryx to carry out this OCR operation on a batch of files?
 
Thanks,
Ben
 
 
 
Alteryx Certified Partner
At a guess you read the files in with a blob input then perform the call for each row (having a blob for each record)
Bolide

Looked at the php version and they are using curl with upload option. Not sure the DL tool has that option even though it uses curl.

 

You might need to do this in curl and use command tool to call curl outside alteryx.  Would be intersted to know if this is possible within DL tool also.

 

curl_setopt($session, CURLOPT_URL, $url);
curl_setopt($session, CURLOPT_USERPWD, "$username:$license_code");

curl_setopt($session, CURLOPT_UPLOAD, true);
curl_setopt($session, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($session, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($session, CURLOPT_TIMEOUT, 200);
curl_setopt($session, CURLOPT_HEADER, false);

 

from curl man

-T, --upload-file <file>

This transfers the specified local file to the remote URL. If there is no file part in the specified URL, Curl will append the local file name. NOTE that you must use a trailing / on the last directory to really prove to Curl that there is no file name or curl will think that your last directory name is the remote file name to use. That will most likely cause the upload operation to fail. If this is used on an HTTP(S) server, the PUT command will be used.

Any samples or macros for this? i am trying to use this ocrwebservice as well.

Thank you

Alteryx Partner

Without looking at the specific implementation in the API for a "batch of files", you can use the BLOB tools in Alteryx to create the data necessary for the Download Tool to execute a PUT. It should be straight forward enough to do so for a single file in a batch macro and then call that macro for each file you need to process via the API. The download tool in fact won't do a PUT for any other field type besides a  BLOB.

Labels