Error Code 500 "Internal Error Occurred" while running Google mobiledevices.action method

Viewed 113

I was trying to remotely block some of the devices in my organization by using the Google Admin SDK Rest APIs but for some reason when I am running the mobiledevices.action method it is giving me errors:

Error code-500, message Internal error encountered, domain global, reason backend error, status internal

Error Image

This is the function I was calling to block devices:

def mdmRemove():

    creds = None

    if os.path.exists('token.json'):
        creds = Credentials.from_authorized_user_file('token.json', SCOPES)
    # If there are no (valid) credentials available, let the user log in.
    if not creds or not creds.valid:
        if creds and creds.expired and creds.refresh_token:
            creds.refresh(Request())
        else:
            flow = InstalledAppFlow.from_client_secrets_file(
                'credentials.json', SCOPES)
            creds = flow.run_local_server(port=0)
        # Save the credentials for the next run
        with open('token.json', 'w') as token:
            token.write(creds.to_json())

    service = build('admin', 'directory_v1', credentials=creds)

    # Rsources body 
    actions = {
        'action':'block'
    }

    # Call the Admin SDK Directory API
    
    results = service.mobiledevices().action(customerId='xxxxx',resourceId='xxxxx',body=actions).execute()
    print(results)
0 Answers
Related