Can't create an invokable Flux script using Curl

Hello All,

Please refer to the example to Create an invokable Flux script:

Replaced the Influx token and valid Org_Id and tried importing the script using Postman. Getting the error as shown in the image:

How can I create a Flux script ?
Also, what is the minimum token permissions required for creating a Flux script?

Regards,
gxyDev.

Hello @gxy_dev,
The following worked for me:

curl -X 'POST' \
  'https://us-west-2-1.aws.cloud2.influxdata.com/api/v2/scripts' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Token xxx==' \
  -d '{"name": "myFirstAPIInvokableScript", "description": "a API Invokable Script that gathers the last point from a bucket", "script": "from(bucket:params.mybucket) |> range(start: -7d) |> limit(n:2)","language": "flux"}' 

{"id":"0xxx00", "orgID":"0xxx000", "name":"myFirstAPIInvokableScript", "script":"from(bucket:params.mybucket) |> range(start: -7d) |> limit(n:2)", "description":"a API Invokable Script that gathers the last point from a bucket", "language":"flux", "createdAt":"2022-07-11T22:48:24.987787Z", "updatedAt":"2022-07-11T22:48:24.987787Z"}%      
1 Like

Thank you much for your help.