# Script Only Working from API Docs

**URL:** <https://community.dreamfactory.com/t/script-only-working-from-api-docs/3453>\
**Category:** Server-Side Scripting\
**Created:** [November 21, 2016, 5:09am UTC](https://community.dreamfactory.com/t/script-only-working-from-api-docs/3453 "2016-11-21T05:09:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zerox12](https://avatars.discourse-cdn.com/v4/letter/z/e5b9ba/32.png) [@zerox12](https://community.dreamfactory.com/u/zerox12)\
**Post date:** [November 21, 2016, 5:09am UTC](https://community.dreamfactory.com/t/script-only-working-from-api-docs/3453/1 "2016-11-21T05:09:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zerox12](https://avatars.discourse-cdn.com/v4/letter/z/e5b9ba/32.png) [@zerox12](https://community.dreamfactory.com/u/zerox12)\
**Post date:** [December 2, 2016, 4:33am UTC](https://community.dreamfactory.com/t/script-only-working-from-api-docs/3453/2 "2016-12-02T04:33:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zerox12](https://avatars.discourse-cdn.com/v4/letter/z/e5b9ba/32.png) [@zerox12](https://community.dreamfactory.com/u/zerox12)\
**Post date:** [December 2, 2016, 7:44am UTC](https://community.dreamfactory.com/t/script-only-working-from-api-docs/3453/3 "2016-12-02T07:44:06Z")

</div>

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…
