'base64 encoded pdf string breaks api

I have POST request which contains a json with a base64 string which represents a pdf, this requests fails and I am trying to figure out a solution to it.

I thought it was just encoding it using url_encode but then it seems to lose part of the data when i decode it.

I tried using PHP json encode from the array but same issue.

It might be that the string is more than 25000 chars long but not sure. if someone have ever encountered this issue and have a solution please share it

$pdf = (isset($params['pdf']) && $params['pdf'] != "" ? $params['pdf']  : null);

Please find below a sample of the payload

https://pastebin.com/JK8zTsAG

NOTE: they keep removing my pastebin -

{
    "id":"5555555",
  "pdf": "7CfNe3nszmfAFMOAc3jgsgTMGEfDIMQzCxTvwAMIwgtUKEy9ikGKGCR6fN8LMmj"
}

The above works well but if I add the real pdf base64 string it breaks since its over 20k long.

In short : I am receiving the payload in the pastebin, it contains a base64 string which represents a pdf but when I receive the pdf string (which is really long over 20k characters) it breaks the api.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source