I figured out why this happened:
you must add charset=UTF-8 like this to fix characters and set argument separator to '&' for a workaround to work.
$headers[]='Content-type: application/x-www-form-urlencoded;charset=UTF-8';
$postfields=http_build_query($post,'','&',PHP_QUERY_RFC3986);//inserted via Rest API ąčęėį & ž яшерты
Problem solved (kind of a workaround).