How to write to a Azure Blob Service from Dataiku API endpoint code

Options
ssuhas76
ssuhas76 Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 31
edited July 16 in Using Dataiku

Hello there,

I am trying to save contents of a json object from the API endpoint code. Currently my code looks like this.

The code is written in a python function as part of a API endpoint which receives data in form of a json object.

client = dataikuapi.DSSClient(host, apiKey)
client._session.verify = False
project = client.get_project("XXXXXXXX")

managedfolder = project.get_managed_folder("XXXXXXXXX")

jsonData = data.to_json()
managedfolder.put_file('data1.json',jsonData)

When I run the above code, i get the below error while executing via Testing Queries

Failed: Failed to run function : class 'dataikuapi.utils.DataikuException': com.dataiku.dip.exceptions.UnauthorizedException: Action forbidden

Best Answer

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,209 Dataiker
    Answer ✓
    Options

    Hi @ssuhas76
    ,

    Action forbidden usually indicates the API key you are using doesn't have permission to write to this managed folder.

    You should be able to replicate this in a notebook as well when setting a remote client.

    What type of API key are you using? Personal/Project?
    You can use a project API key but need to provide access to read/write from the project permissions + for the respective managed folder.

    THanks

Answers

  • ssuhas76
    ssuhas76 Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 31
    Options

    Thanks it solved for me. I am using a project level API key. I turned on the writeprojectcontent permission to true. It is working now.

Setup Info
    Tags
      Help me…