Jun-28-2019, 04:06 AM
Trying to leverage an API call to build out a new workflow.
Trying to leverage this API call, which models to this.
Drilling down, it calls fleet dispatch create job which appears to model this.
Unfortunately, what I thought was right is giving me a 404 error. I've put * in the code for the API key, group ID (it's an int) and also the vehicle ID (it's an int). Code is as follows:
I've included the call, the print statement above (replaced vehicle and group id with *), and also the error I get:
Stumped as to why I'm getting the error. Not sure if I'm passing something incorrectly, or missing something. Any suggestions appreciated!
Trying to leverage this API call, which models to this.
Drilling down, it calls fleet dispatch create job which appears to model this.
Unfortunately, what I thought was right is giving me a 404 error. I've put * in the code for the API key, group ID (it's an int) and also the vehicle ID (it's an int). Code is as follows:
import time import samsara from samsara.rest import ApiException from pprint import pprint # create an instance of the API class api_instance = samsara.FleetApi() access_token = '*' # str | Samsara API access token. group_id = * dispatch_jobs = [{'external_identifier': None}, {'driver_id': None}, {'vehicle_id': *}, {'job_state': None}, {'scheduled_arrival_time_ms': 1561975200000}, {'started_at_ms': 1561968000000}, {'completed_at_ms': None}, {'cancelled_at_ms': None}, {'job_created_at_ms': None}, {'notes': "Your Old House"}, {'destination_name': "Old Home"}, {'destination_address': "3935 41st Ave Dr, Moline, IL 61265"}, {'destination_lat': None}, {'destination_lng': None}] create_dispatch_jobs_param = samsara.CreateDispatchJobsParam(group_id, dispatch_jobs) print(create_dispatch_jobs_param) try: # /fleet/dispatch_jobs/create api_response = api_instance.create_fleet_dispatch_jobs(access_token, create_dispatch_jobs_param) pprint(api_response) except ApiException as e: print("Exception when calling FleetApi->create_fleet_dispatch_jobs: %s\n" % e)
I've included the call, the print statement above (replaced vehicle and group id with *), and also the error I get:
Error:python3 post.py
{'dispatch_jobs': [{'external_identifier': None},
{'driver_id': None},
{'vehicle_id': *},
{'job_state': None},
{'scheduled_arrival_time_ms': 1561975200000},
{'started_at_ms': 1561968000000},
{'completed_at_ms': None},
{'cancelled_at_ms': None},
{'job_created_at_ms': None},
{'notes': 'Your Old House'},
{'destination_name': 'Old Home'},
{'destination_address': '3935 41st Ave Dr, Moline, IL'
'61265'},
{'destination_lat': None},
{'destination_lng': None}],
'group_id': *}
Exception when calling FleetApi->create_fleet_dispatch_jobs: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Date': 'Thu, 27 Jun 2019 14:45:21 GMT', 'Content-Type': 'text/plain; charset=utf-8', 'Content-Length': '19', 'Connection': 'keep-alive', 'Request-Id': '4878a7dc', 'X-Content-Type-Options': 'nosniff'})
HTTP response body: 404 page not found
Stumped as to why I'm getting the error. Not sure if I'm passing something incorrectly, or missing something. Any suggestions appreciated!