Month: August 2020

Fortimail REST API Examples

The fortimail rest api documentation is not great.

It can be alot better. Although it can also be a lot worse.

I will go through a few examples of common things that can be done with the api over HTTP (It isn't rest although they think it is) - no hypermedia and making use of reqAction as preference over HTTP verbs - although HTTP verbs are used.

An excerpt from the API docs:

Supported values for 'reqAction' attribute of all JSON requests:

1 ---GET
14 ---MOVE

Note: If reqAction is present in JSON, it takes precedence over HTTP method header (i.e. HTTP GET/POST/PUT/DELETE)

How to fix Django OperationalError /admin/auth/user/add/ SAVEPOINT …_x1 does not exist

This is a weird one, an error I had never got until I used an external MySQL (Maria) DB Instance with Django.

The steps to recreate this error would be:

  1. As an Admin try and add another user from the admin section

You will get an error like this:

OperationalError /admin/auth/user/add/
error(1305, 'SAVEPOINT s139787825936192_x1 does not exist')

In my case the system had the following attributes:

  • CentOS 7
  • python mysql connecor: mysqlclient
  • django 2.2.15
  • Server version: 5.5.30 (ProxySQL)

According to this stackoverflow post on the subject, it was to do with the MySQL-Python connector.

The answerer recommends using the mysqlclient python package. Thing is...I am using it.

What I Tried

  • Upgrading to django 3
  • Downloading and installing the lastest python MySQL connectors
  • Installing mariadb libs locally on the app server
  • Uninstall mysqlclient package and use pip install PyMySQL
  • Downgrade from mysqlclient==2.0.0. to mysqlclient==1.4.6

What Worked

I moved to using a local database:

Server version: 10.5.4-MariaDB MariaDB Server