Quantcast
Channel: DreamFactory Forum - Latest posts
Viewing all articles
Browse latest Browse all 5028

Script Only Working from API Docs

$
0
0

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.


Viewing all articles
Browse latest Browse all 5028

Trending Articles