Script Only Working from API Docs


#1

I have a very basic python script that checks if a first_name is taken. It works perfectly from API docs, but the exact same JSON request sent from my Android app fails.

Script:

API_KEY = 'xxxxxxxxxxxxxxxxxx'

payload = event.request.payload

if payload:
    if 'first_name' not in payload:
        raise ValueError('User name field missing')
    
user_name = payload.first_name

if user_name == '':
    raise ValueError('User name field required')

response = platform.api.get('system/user?api_key=' + API_KEY + '&filter=first_name%3D' + user_name)
response_string = response.read().decode('utf-8')
response_bunch = bunchify(json.loads(response_string))

if response_bunch.resource:
    raise ValueError('User name is not available')

The error:

{“error”:{“context”:null,“message”:“resource”,“code”:500,“trace”:[…

The “message” being “resource” is suspicious, but I don’t know how to trouble shoot it when the exact same API call from the docs is working.

The role for this app has script access enabled.

One other note, I have preprocess and post process scripts on user register. If I disable the preprocess script the user register works and the post process script runs.


DF 2.4.1 Add extra information upon open registration
#2

No clues on why this script doesn’t run? Anything would be helpful at this point because I have yet to solve this.


#3

I tried to trouble shoot this some more.

I found that response_bunch only ever has one value, “error”. I do not know if there is a bug here, or some special protection on system/user, but I have tried every possible combination to make this work and have not had success. Seems it’s only possible to reach this endpoint from API Docs…