Script to run Export task

Hello All,
I just evaluating Nexus PRO 3.29.2-02 on Windows. My goal is to allow users to export repositories.
So created npm proxy repository and task of type Repository - Export assets.
When I am running this task from Nexus GUI page - everything is working and assets exported to local folder.
I created small PowerShell script:

$cred = Get-Credential
$export_req = Invoke-WebRequest -Uri http://127.0.0.1:8081/service/rest/v1/tasks/9667b7e6-f1ce-46e1-9c29-3ea79553884a/run -Method POST -Credential $cred -ContentType ‘application/json’

It is failed to run a task and here is Nexus log:
2021-02-16 11:10:39,460+0200 WARN [qtp1525599147-613] *UNKNOWN org.sonatype.nexus.siesta.internal.AuthorizationExceptionMapper - (ID efa05190-8d99-4415-80b9-19627daf0648) Response: [403] (no entity/body); mapped from: org.apache.shiro.authz.AuthorizationException: User is not permitted: nexus:tasks:start

I tried similar with Python:

h = {‘Content-type’: ‘application/json’}
data = {‘username’:‘admin’, ‘password’:‘AAAAAA’}
r = requests.post(‘http://127.0.0.1:8081/service/rest/v1/tasks/9667b7e6-f1ce-46e1-9c29-3ea79553884a/run’, data=json.dumps(data), verify=False, headers=h)
print(“Run task\n Response:”,r.text, "Headers: ",r.headers, “\n”)

But result is a same.
I tried to create different user, not admin and gave him different privileges.
Nothing helps…
Any idea?

You should grant your user the permission specified in the error message. Note, that is not a permission that should be granted to ordinary users.

Hello @mpiggott ,
I am using admin user in my script. Not sure what do you mean by “grant your user the permission”.
Can you explain, please?

This is what your message says