# Openflexure command

**URL:** <https://openflexure.discourse.group/t/openflexure-command/918>\
**Category:** Request Help\
**Created:** [18 June 2022 01:27 UTC](https://openflexure.discourse.group/t/openflexure-command/918 "2022-06-18T01:27:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pawel1010](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@pawel1010](https://openflexure.discourse.group/u/pawel1010)\
**Post date:** [18 June 2022 01:27 UTC](https://openflexure.discourse.group/t/openflexure-command/918/1 "2022-06-18T01:27:04Z")

</div>

In my python program I used

```auto
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:

```auto
    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?

---

<div class="post-metadata">

**Author:** ![r.w.bowman](https://yyz2.discourse-cdn.com/free1/user_avatar/openflexure.discourse.group/r.w.bowman/32/15_2.png) [@r.w.bowman](https://openflexure.discourse.group/u/r.w.bowman)\
**Post date:** [23 June 2022 12:55 UTC](https://openflexure.discourse.group/t/openflexure-command/918/2 "2022-06-23T12:55:43Z")

</div>

hmm, that is odd. The [API docs](https://redocly.github.io/redoc/?url=https://build.openflexure.org/openflexure-microscope-server/latest-api.yaml#tag/actions/paths/~1api~1v2~1actions~1stage~1move~1/post) 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?
