Can't set right permissions on folder share via OCS API

Nextcloud version (eg, 19.0.3):
Operating system and version (eg, Debian 10.5):
Apache or nginx version (eg, Apache 2.4.38):
PHP version (eg, 7.4.10):

The issue you are facing: I’m trying to set permissions on share of the folder via OCS API. I need to set permission on link for upload only.
I used docs from here https://docs.nextcloud.com/server/19/developer_manual/client_apis/OCS/ocs-share-api.html

Is this the first time you’ve seen this error? (Y/N): Yes

Steps to replicate it:

  1. Send OCS API request POST https://{{nextcloud_base_url}}/ocs/v2.php/apps/files_sharing/api/v1/shares via Postman or curl with body in x-www-form-urlencoded
path: /your_folder_path
shareType: 3
permissions: 4
  1. Get XML response where permissions field will be 17, not 4 as was requested
<?xml version="1.0"?>
<ocs>
    <meta>
        <status>ok</status>
        <statuscode>200</statuscode>
        <message>OK</message>
    </meta>
    <data>
        <id>36</id>
        <share_type>3</share_type>
        <uid_owner>admin</uid_owner>
        <displayname_owner>admin</displayname_owner>
        <permissions>17</permissions>
        ...
    </data>
<ocs>

The output of your Nextcloud log in Admin > Logging:

Error	no app in context	InvalidArgumentException: 		2020-11-19T13:04:41+0300
Error	PHP	POST Content-Length of 33560990 bytes exceeds the limit of 8388608 bytes at Unknown#0		2020-11-19T11:57:43+0300
Error	sharebymail	Swift_TransportException: Connection could not be established with host 127.0.0.1 :stream_socket_client(): unable to connect to 127.0.0.1:25 (Connection refused)		2020-11-19T11:23:24+0300

Hi! Did you solve it somehow? I’m having same problem with curl. Permissions are never set and only 1 is accepted. Although some checking is done, because if I enter 100, then I get error.

There’s an issue as well

To get around the error you need send PUT query with the necessary privileges after creating the folder with POST request