Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[python] Help with preprocess script #7

Open
zerox1212 opened this issue Nov 23, 2016 · 0 comments
Open

[python] Help with preprocess script #7

zerox1212 opened this issue Nov 23, 2016 · 0 comments

Comments

@zerox1212
Copy link
Contributor

Does someone have an idea why this script works from API Docs, but not from an actual API call (in my case from Android)

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')

From API docs it works as expected. If a first name is taken, it says "user name not available". If there are no issues the user is registered as normal.

Calling from my Android app I always get the same response if this script is active.
{"error":{"context":null,"message":"resource","code":500,"trace":[....

@zerox1212 zerox1212 changed the title Help with preprocess [python] Help with preprocess script Nov 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant