Solved

Why the Error 403 doing Data Engineer Basics - “Learn to Use the Cognite Python SDK “ Course."?

  • 12 April 2024
  • 6 replies
  • 42 views

Doing the ‘hands-on’ for Data Engineer Basics - “Learn to Use the Cognite Python SDK “ Course."

The instructions said “Make sure that the data set is write-protected”. So I had under Step 1:

I then ran without error:

That was YESTERDAY.

TODAY, the 2nd block of commands threw an error: “CogniteAPIError: Resource not found. This may also be due to insufficient access rights. | code: 403 | X-Request-ID: f9083e61-8310-9462-9fb6-69f8da1299f3”

So, after trying this and that, I changed the generated data_set to write protected = False in the 1st block of code above.

 

--- >  The 2nd block of commands now works, just like YESTERDAY.

 

Q1. Why did  ‘write protected = True’ work YESTERDAY, but not TODAY, giving Error 403?

Q2. Why does ‘write protected = False’ work, but not ‘write protected = True’ , TODAY, that is?

From where does this inconsistency come? Someone?

Thank you!

Douglas 

 

icon

Best answer by Andrian Gasper 12 April 2024, 14:49

View original

6 replies

Userlevel 1
Badge +2

Hi @Mugless Durry 

 

The write_protected field means: 
    To write data to a write-protected data set, you need to be a member of a group that has the “datasets:owner” action for the data set.

The weird experience you have observed could be to due someone else archiving the dataset. 

Try adding a check in your code to see if the data set exists first. 
 

ds_names = [ds.name for ds in c.data_sets.list(limit=-1)]
if "world_info_myname" not in ds_names:
raise Exception("Dataset does not exist in project.")

Let me know if anything. 

Thanks Andrian,

In both cases, YESTERDAY (working) and TODAY (not working), I checked in CDF for the data_set and confirmed that the data_set was indeed created - I checked the data_set_id in CDF.

So, I deduce from your reply:

<<To write data to a write-protected data set, you need to be a member of a group that has the “datasets:owner” action for the data set >>

that overnight I ceased to be a member of a group that has the “datasets:owner” action for ANY data_set that may be created in the future (relative to the membership change). Is that correct? 

Userlevel 1
Badge +2

That could be the case but seems weird.

Try creating another write_protected=True dataset and try write some mock data to it.
This should test your theory. 

Yes, another write_protected=True dataset causes the same error.

Userlevel 1
Badge +2

@Mugless Durry 
Since it is a learning course, I suppose the solution would be to just create the data set as write_protected=False in this case. 
 

Thanks Andrian

Reply