MiR 250 Robot with Rest API need help with help with HTTP Post

OK, so I am trying to interface with a MiR 250 Robot.
At this point I need to simply supply a list of "Missions" stored in the system.
And then have the user select a Mission and put it in the robots queue.

I have no problem with the get request, but get a 400 response when using a Post to send it a new Mission.

This is proof of concept, so the Mission value is hardcoded but it is correct.

import json
ip='1.1.1.1'
host='http://' + ip + '/api/v2.0.0/'

#Format Headers
headers = {}
headers['Content-Type']='application/json'
headers['Authorization']=' Basic Bla Bla Bla'
headers['Accept-Language']='en-US'

get_missions = system.net.httpGet(host + 'missions', headerValues = headers)
#print(get_missions)
mission_id = {"mission_id": "ea8895da-79e5-11ec-8aff-000129a09448"}
post_mission = system.net.httpPost(host + 'mission_queue', json = mission_id, headerValues=headers)
#print(headers)

Here is a working example from their documentation for context.


Any Input would be appreciated.
Thanks,
Brandon

system.net.httpPost doesn't have a json keyword arg.

What version of Ignition are you using? If you're on 8+ I'd start by switching to system.net.httpClient.

1 Like

Yes, I am 8+.
I started with some older sample code, so that would explain the json.

I tried updating put am still having the same result.

This is what I tried.

client = system.net.httpClient()
response = client.post(host + 'mission_queue', params=mission_id, headers=headers)

You probably want data=mission_id, not params, based on your documentation.

That did the trick, Thanks!!