Openflexure command

In my python program I used

microscope.moveMeasure = mm


# homing routine
pos = microscope.position
print("Current position: " + json.dumps(pos))
print("Homing")
pos['x'] = 0
pos['y'] = 0
pos['z'] = 0
#microscope.move(pos)

zStep = 10
zRange = 1500
maxValue = -1
maxPosition = -1
for z in range(-micronToStep(zRange/2), micronToStep(zRange/2) - micronToStep(zStep), micronToStep(zStep)):
    pos = microscope.position
    pos['x'] = 0
    pos['y'] = 0
    pos['z'] = z
    values = microscope.moveMeasure(microscope, pos, 5)

and I get an error:

    values = microscope.moveMeasure(microscope, pos, 5)
  File "main.py", line 36, in mm
    response = self.post_json("/actions/stage/move", pos)
  File "/usr/local/lib/python3.6/site-packages/openflexure_microscope_client/microscope_client.py", line 64, in post_json
    r.raise_for_status()
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 422 Client Error: UNPROCESSABLE ENTITY for url: http://192.168.0.226:5000/api/v2/actions/stage/move

The json I use is: response = self.post_json("/actions/stage/move", pos)

What should I change?

hmm, that is odd. The API docs suggest that a dictionary with keys called "x", "y", and "z" should be valid. If you add in pos['absolute']=True (assuming you want absolute rather than relative moves) this might fix it?

The HTTP error you’re getting suggests that the payload (pos) is not what the endpoint expects, so it’s worth printing out pos just to check, because my reading of your code is that it should be correct.

If you look at the server logs (ofm log on the Raspberry Pi) is there more helpful information?