Skip to main content
Muhammad
Seasoned ⭐️
Seasoned ⭐️
October 7, 2024
Solved

Cognite python SDK - 403 Error

  • October 7, 2024
  • 10 replies
  • 153 views

I have been trying to create an asset but I keep on receiving 403 error consistently. Below are the images attached respectively. It seems like I don’t have access for asset creation. Can anyone help me to rectify this issue please?

    Best answer by Mithila Jayalath

    @Muhammad As per the support ticket since you were able to solve the issue, I’ll mark this question as resolved.

    10 replies

    Sofie Haug
    Expert ⭐️⭐️⭐️⭐️
    Cognite Academy Instructor
    October 7, 2024

    Hi @Muhammad 

    Can you send a link to the course you are following? Also, if you can include a screenshot of the authentication section in the code

     

    Sofie

    Sofie | Cognite Academy
    Muhammad
    Seasoned ⭐️
    MuhammadAuthor
    Seasoned ⭐️
    October 7, 2024

    Hi @Sofie Haug ,

    I was able to authenticate using web-browser successfully. Furthermore, I have created the dataset (first step). Here is the link of what I’am working on; using-cognite-python-sdk/notebooks at main · cognitedata/using-cognite-python-sdk · GitHub. Attached below is the code authentication snippet.

    Mithila Jayalath
    Expert ⭐️⭐️⭐️⭐️
    Expert ⭐️⭐️⭐️⭐️
    October 7, 2024

    Hi @Muhammad,

    Can you please change the code as below and check again?

    world_asset = client.assets.create(
    Asset(
    name="world",
    description="Root asset representing the entire world",
    data_set_id=ds.id # Associate with the dataset you created
    )
    )

     

    Muhammad
    Seasoned ⭐️
    MuhammadAuthor
    Seasoned ⭐️
    October 7, 2024

    I have tried all possible ways provided in the notebooks provided it didn’t work. Including the attached code below by replacing the pump with the “world”. Yet, it didn’t work. 

    Mithila Jayalath
    Expert ⭐️⭐️⭐️⭐️
    Expert ⭐️⭐️⭐️⭐️
    October 7, 2024

    @Muhammad As per screenshot of the authetication code you have defined the SDK client as “client” not as “c”. That is why I asked to replace c.assets.create to client.assets.create

    Or you can define your SDK client as below.

    c = CogniteClient(config)

    I hope my answer is clear to you. 

    Muhammad
    Seasoned ⭐️
    MuhammadAuthor
    Seasoned ⭐️
    October 7, 2024

    I have that into consideration. Furthermore, I have re-adjust the code per your instruction and yet the error message remain the same. Attached are the code I have been using. From A-C respectively.

    Mithila Jayalath
    Expert ⭐️⭐️⭐️⭐️
    Expert ⭐️⭐️⭐️⭐️
    October 7, 2024

    Thank you for the update @Muhammad.

    Can you please hover the cursor on top of line world_asset = c.assets.create and let me know what is displayed? The red uderline indicates something is wrong.

     

    Muhammad
    Seasoned ⭐️
    MuhammadAuthor
    Seasoned ⭐️
    October 7, 2024

    Sure thing. Below attached. 

    Mithila Jayalath
    Expert ⭐️⭐️⭐️⭐️
    Expert ⭐️⭐️⭐️⭐️
    October 7, 2024

    @Muhammad I will create a support ticket for this, so our support team can follow up and help you to resolve this issue.

    Mithila Jayalath
    Expert ⭐️⭐️⭐️⭐️
    Expert ⭐️⭐️⭐️⭐️
    November 6, 2024

    @Muhammad As per the support ticket since you were able to solve the issue, I’ll mark this question as resolved.