Operate Filemaker from Python

I tried to operate Filemaker using Python.

environment

server windows server 2012 R2 Filemaker server 17

client windows 10 pro office 2016

Python 3.8.1 Pycharm Community Edition 2020.2

Thing you want to do

Search and update the appropriate database uploaded to the Filemaker server. The envisioned work is master maintenance. I think that Filemaker is often used like CRM, but I think it would be convenient if the master could be poured from the accounting system. Well, maybe I should do it by hand.

Preparation

It is assumed that Filemaker Server has a suitable database. It is assumed that there are already users who can access this database with the Web API published. It is assumed that the certificate for SSL communication has not been installed.

Use requests. Please import.

Get access token

headers = {'Authorization': 'Basic XXXXXXXXXXXXXXXX', 'Content-Type': 'application/json'}
r_post = requests.post(https://[hostname]/fmi/data/v1/databases/[databasename]/sessions', headers=headers, verify=False)

What was written in Excel can be realized in just two lines! Great Python. After Basic, copy the idpw base64 encoded string. There may be a better way around here. Set [hostname] and [databasename] according to your environment.

Search for

headers = {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json'}

query = {'query': [{"Search field name": keyword}]} r_post = requests.post( https://[hostname]/fmi/data/v1/databases/[databasename]/layouts/[layoutname]/_find, json=query, headers=headers, verify=False)

It's very easy. It seems that there are two ways to specify json and data in requests.post, but if Filemaker is the other party, json is easy. For the search keyword, it seems that you can use how to specify in the search mode of Filemaker, such as * or =.

Update

headers = {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json'}

fieldData = {'fieldData': {'Update target field name': value1,'Update target field name': value2}} r_post = requests.patch(https://[hostname]/fmi/data/v1/databases/[databasename]/layouts/[layoutname]/records/[recordId], json=fieldData, headers=headers, verify=False) It took me two hours to find out that the method was a patch ... Not enough devotion.

in conclusion

Now you can read your CSV file line by line and partially update the master database on FileMaker. If you want to replace all the data at once, you don't have to do this annoying thing.

Recommended Posts

Operate Filemaker from Python
Operate neutron from Python!
Operate LXC from Python
Operate an I2C-connected display from Python
Operate DynamoDB from Python like SQL.
sql from python
MeCab from Python
Operate Sakura's cloud object storage from Python
Use thingsspeak from python
Touch MySQL from Python 3
Operate Redmine using Python Redmine
Use fluentd from python
Access bitcoind from python
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
Python from or import
Use MySQL from Python
Run python from excel
Install python from source
Operate Kinesis with Python
Execute command from Python
Use MySQL from Python
Operate Blender with Python
Operate the schedule app using python from iphone
Manipulate riak from python
Force Python from Fortran
Use BigQuery from python.
Execute command from python
Operate Excel with Python (1)
[Python] Read From Stdin
Use mecab-ipadic-neologd from python
Operate Excel with Python (2)
Operate mongoDB from python in ubuntu environment ① Introduction of mongoDB
[AWS] Operate SQS from SDK (send / receive) [Python] [Node.js]
Flatten using Python yield from
Call CPLEX from Python (DO cplex)
Deep Python learned from DEAP
Operate Excel with Python openpyxl
Post from Python to Slack
Operate TwitterBot with Lambda, Python
Grammar features added from Python3.6
Cheating from PHP to Python
Make MeCab available from Python3
Information obtained from tweet_id (Python)
OCR from PDF in Python
Run illustrator script from python
Use MySQL from Anaconda (python)
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
Study from Python Hour4: Object-oriented ②
Query Athena from Lambda Python
Access Oracle DB from Python
[Note] Operate MongoDB with Python
Study from Python Hour3: Functions
Start / stop GCE from python
Stop Omxplayer from Python code
Switch from python2.7 to python3.6 (centos7)
Connect to sqlite from python
Install pyenv from Homebrew, install Python from pyenv
Study from Python Hour4: Object-oriented ①
Python naming convention (from PEP8)
[Python] [SQLite3] Operate SQLite with Python (Basic)