davidhamann/python-fmrest

Present field reported as missing

Closed this issue · 2 comments

I think I'm running into a bug where a field that is present in the layout is not found when doing a query.

foundset = fms.get_records(range_=2)
print(len(foundset[0].keys()))
print(foundset[0]['k.year'])

returns

206
15-16

but

find_query = [{'k.year': '15-16'}]
foundset = fms.find(find_query)

returns

---------------------------------------------------------------------------
FileMakerError                            Traceback (most recent call last)
<ipython-input-29-feafd4c0fd59> in <module>()
      1 find_query = [{'k.year': '15-16'}]
----> 2 foundset = fms.find(find_query)

~/Documents/kai_ming/data_analysis/venv_km3/lib/python3.6/site-packages/fmrest/server.py in find(self, query, sort, offset, range_, portals)
    311         }
    312 
--> 313         response = self._call_filemaker('POST', path, data=data)
    314 
    315         return Foundset(self._process_foundset_response(response))

~/Documents/kai_ming/data_analysis/venv_km3/lib/python3.6/site-packages/fmrest/server.py in _call_filemaker(self, method, path, data, params)
    423         if self.last_error != 0:
    424             raise FileMakerError(self._last_fm_error,
--> 425                                  response_data.get('errorMessage', 'Unkown error'))
    426 
    427         return response

FileMakerError: FileMaker Server returned error 102, Field is missing

Hi @HawkinsJM,

Thanks for the issue report.

The problem might be the literal dot in your field name k.year. If you change the field name (for example) to k_year, it should work.

I just tried to reproduce the issue here with the latest fmrest version and FMS17. I have the same problem for every request that contains a field name with a dot, but get a different error ("960, Parameter is invalid").

To make sure it's not an issue with the library, I manually created a curl request for the same endpoint, which gives me the same (problematic) result:

curl -H 'Authorization: Bearer <token>' -H 'Content-Type: application/json' -d '{"query": [{"k.year": "15-16"}]}' 'https://<host>/fmi/data/v1/databases/Contacts/layouts/Demo/_find'

Although it may not be directly related, FileMaker's native JSON parsing functions have similar issues with dots in keys; see here: https://community.filemaker.com/thread/179782

I'll look closer into it as soon as I find the time, but I fear that it might just be the FileMaker Server code and nothing I can control. Renaming your field seems, for now, the easiest workaround, sorry!

Could you, nevertheless, give me the output of

import fmrest
fmrest.__version__

and report your FileMaker Server version? I assume it's v16 as you are using the range_ parameter!?

PS.: In case you have some indirection sources related to k.year and cannot easily rename it, one idea for now would be to create a stored calc field that mirrors the value but has a different name.

Thanks for the response and your work on the API. We changed the k.year to k_year and now it works as expected, so the '.' must be the issue. Thanks for the workaround, we will use that for now.

We are using FileMaker 16 and fmrest version '0.3.0'.