Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
API Call Gets 404 Error
#1
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:

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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 error from Mysql call AkaAndrew123 1 3,383 Apr-28-2021, 08:16 AM
Last Post: AkaAndrew123
  In this function y initially has no value, but a call to foo() gives no error. Why? Pedroski55 8 3,415 Dec-19-2020, 07:30 AM
Last Post: ndc85430
  Python: Call function with variabele? Ending in error. efclem 5 2,877 Apr-22-2020, 02:35 PM
Last Post: buran
  Using VBA to Call a Python script causes error in pyodbc connector pcarra 1 2,775 Jun-11-2019, 04:14 PM
Last Post: pcarra
  call dict object result key error lateublegende 2 2,987 May-15-2019, 01:08 PM
Last Post: lateublegende

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020