Skip to main content
Solved

Cognite python SDK - 403 Error


Muhammad
Committed
Forum|alt.badge.img+1

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.

View original
Did this topic help you find an answer to your question?

10 replies

Sofie Haug
Practitioner
Forum|alt.badge.img+7
  • Cognite Academy Instructor
  • 151 replies
  • 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


Muhammad
Committed
Forum|alt.badge.img+1
  • Author
  • Committed
  • 7 replies
  • 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
Seasoned Practitioner
Forum|alt.badge.img

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
Committed
Forum|alt.badge.img+1
  • Author
  • Committed
  • 7 replies
  • 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
Seasoned Practitioner
Forum|alt.badge.img

@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
Committed
Forum|alt.badge.img+1
  • Author
  • Committed
  • 7 replies
  • 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
Seasoned Practitioner
Forum|alt.badge.img

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
Committed
Forum|alt.badge.img+1
  • Author
  • Committed
  • 7 replies
  • October 7, 2024

Sure thing. Below attached. 


Mithila Jayalath
Seasoned Practitioner
Forum|alt.badge.img

@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
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • 369 replies
  • Answer
  • November 6, 2024

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


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings