TransactionTooLargeException when try to send an image over POST request

53 views
Skip to first unread message

Eesti dev

unread,
Sep 10, 2025, 4:34:58 PMSep 10
to Automate for Android
I am trying to use an API called nutrient.io to convert images to pdfs. 
So I have a fiber that allows me to take a picture and then do a POST request to get a pdf out of it. 
I did a lot of debugging to format properly the request, since is a multipart form, and I think I finally got it, but then I am getting back a TransactionTooLargeException.

Thanks in advance!

Henrik "The Developer" Lindqvist

unread,
Sep 10, 2025, 5:37:50 PMSep 10
to Automate for Android
How  do your create the multipart request body?
Don't create a text of the whole body including the image data as Request content body, instead use Request content path to let the block include the image file, e.g:
  • Request method: POST
  • Request content type= "multipart/form-data;boundary=BoUnDaRy"
  • Request content body= [ "--BoUnDaRy\r\nContent-Disposition:form-data;name=image;filename=image.jpg\r\n\r\n", "\r\n--BoUnDaRy--\r\n" ] 
  • Request content path: image.jpg

Eesti dev

unread,
Sep 11, 2025, 4:01:04 AMSep 11
to Automate for Android
Hello, 
I have tried different ways. Current one is:
    • Request method: POST
    • Request content type= "multipart/form-data;boundary=BoUnDaRy"
    • Request content body= ["--autBound\r\nContent-Disposition: form-data; name=instructions;\r\n\r\n" ++
      jsonEncode({"parts": [{"file": "file"}]}) ++
      "\r\n\r\n--autBound\r\nContent-Disposition:form-data;name=file;filename=" ++
      imagePath ++ "\r\n\r\n",
      "\r\n--autBound--\r\n"] 
    • Request content path:  imagePath 
    • Request headers: Bearer token (this works, I get response from the API with other trials)
    Image path comes from block "Capture image".

    This is how the nutrient API request should look like (taken from their documentation):
    POST https://api.nutrient.io/build HTTP/1.1 Content-Type: multipart/form-data; boundary=--customboundary Authorization: Bearer token --customboundary Content-Disposition: form-data; name="instructions" Content-Type: application/json { "parts": [ { "file": "file" } ] } --customboundary Content-Disposition: form-data; name="file"; filename="input.png" Content-Type: image/png (file data) --customboundary--

    I have also tried with this other content body. 
    • Request content body= ["--autBound\r\nContent-Disposition: form-data; name=instructions;\r\n\r\n" ++
      jsonEncode({"parts": [{"file": "file"}]}) ++ "\r\n\r\n",
      "--autBound\r\nContent-Disposition:form-data;name=file;filename=" ++
      imagePath ++ "\r\n\r\n",
      "\r\n--autBound--\r\n"] 
    But then I get API error:
    {"error":{"details":"There was an error with one or more parts of the instructions.","failingPaths":[{"details":"must be a valid JSON object","path":"$.instructions"}],"requestId":"****","status":400,"supportUrl":"https://www.nutrient.io/api/support/"}}

    Hope this gives a better context. 

    Henrik "The Developer" Lindqvist

    unread,
    Sep 11, 2025, 7:54:01 AMSep 11
    to Automate for Android
    Both parts are missing their Content-Type, also filename should be included, not the whole path or just leave it entirely since it should be optional. Try:
    ["--autBound\r\nContent-Disposition:form-data;name=instructions\r\nContent-Type:application/json\r\n\r\n{{"parts":[{"file":"file"}]}; jsonEncode}\r\n--autBound\r\nContent-Disposition:form-data;name=file;filename=\"{split(imagePath,"/")[-1]}\"\r\nContent-Type:{imagePath;mimeType}\r\n\r\n",
    "\r\n--autBound--\r\n"] 

    Eesti dev

    unread,
    Sep 15, 2025, 5:50:58 AMSep 15
    to Automate for Android
    Thanks!  Got it working. 
    Reply all
    Reply to author
    Forward
    0 new messages