Skip to main content

Can someone help me with setting up the HTTP-Connector with a form-data type API? Is there an example? Normally I set up a raw JSON body, but now the API is expecting different input. I attached a Postman printscreen which is succesful and what I need in the HTTP-Connector. I have read 2 other topics about this, but none gave me a proper solution of how exactly the input of the HTTP-Connector should look like and what data-types should be used in the Process Flow.

 


You can try to generate client code (e.g. a cURL request) to get a better idea of what the headers and body should look like for a form-data request.

More info in the postman docs.


Hi Anne, thanks for your quick reply. I saw those, but (and maybe it is just me) but I do not know how to translate that to the input parameters of the HTTP-Connector. F.e. can you tell me how to translate underlying cURL code into the parameters of the HTTP-Connector? Especially the --form is something I do not know what to do with. Thanks in advance!

 

curl --location --request POST 'https://api.ocr.space/parse/image' \
--header 'Content-Type: multipart/form-data;boundary=abcde12345' \
--form 'language="dut"' \
--form 'isOverlayRequired="false"' \
--form 'issearchablepdfhidetextlayer="false"' \
--form 'iscreatesearchablepdf="false"' \
--form 'filetype="application/pdf"' \

 


Ah, the cURL doesn’t help that much, no.

Perhaps the Mozilla documentation on POST will be more helpful, it shows how form data translates into a request body.

 


I maybe found the information you wanted me to see, but than I have the same question, how do I implement it.

POST /parse/image HTTP/1.1
Host: api.ocr.space
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Length: 870474

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="language"

dut
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="isOverlayRequired"

false
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="issearchablepdfhidetextlayer"

false
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="iscreatesearchablepdf"

false
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="filetype"

When I create the content input like this:

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="language"

dut
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="isOverlayRequired"

false
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="issearchablepdfhidetextlayer"

false
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="iscreatesearchablepdf"

false
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="filetype"

application/pdf

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="OCREngine"

1
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="isTable"

true
----WebKitFormBoundary7MA4YWxkTrZu0gW--

 the API call still fails. Would you do the same?


This should work as expected. Did you set the Content-Type header with the boundary properly in the http connector?


Yes, but maybe some layout is not correct. If you say this is the right way, I will first try to see if I can make it work. Thanks for now and I will post my outcome here


Hello @marcjan,

There’s an example here that might be useful to you.


Thanks for all your help. Turns out the string is very space sensitive and the boundery set in the header should not contain --. Now it works! Thanks to your replies I could focus more specifically on the problem.