Important: This is an old version of the Auto Job Importer. Please see this article for the latest version.
Before setting up automated imports, please first complete a test CSV import. If you have questions regarding importing a test CSV, please reach out directly to your Customer Success Manager.
In order to use the Job Importer, first you need to create an API Key. An API key is a unique token that allows an application to access a subset of your data. Your API Key should be treated like passwords and be kept secure.
Creating an API Key
In order to create an API key follow these steps on the machine you'll be running the MachineMetrics Job Importer service on. First, navigate to the API Keys settings page by clicking Settings on the sidebar navigation and then selecting API Keys from the list.
In the dialog, give the API Key a descriptive name such as, “Job Importer”. You'll also need to check the box labeled “erp” which gives the key the ability to import jobs. Click on the “Save Changes” button to create your key.
Now the form should be displaying your Access Token. PLEASE NOTE: Do not close this form until you have copied your access token as you cannot view this value again. If you close this form you will need to delete the API Key you created and create a new one.
Installing the Job Import Service
Run the Job Importer Installer on a Windows PC. Follow the prompts and eventually you will be prompted to configure a few options for the Job Importer Service. The “Jobs Folder” option is the folder where the service will look for the job file to import into MachineMetrics. If this location is a Network Share, it must be the full UNC path and not a mapped Network Drive as these are mapped on a per-user basis. Example, I may want the put the file in the “W:\ERP\JobExport” where “W:” is mapped from “\\Share\Integrations” in this case the full path would be “\\Share\Integrations\ERP\JobExport”.
The “File Format” option specifies whether the job files will be in the MachineMetrics CSV format or another supported format. Finally, the “API Key” field is where you're going to paste your API access token. Continue through the installation prompts until the installation is complete. Once complete, put a copy of your jobs file in the folder you specified and the jobs will automatically be uploaded into MachineMetrics.
The import will start within 30 seconds of putting the import file in the correct folder. It will load faster or slower depending on the size, but generally you can expect it to be uploaded within a minute of placing the file in the folder. If it’s successful, it’ll go into a folder called Completed
, if it fails it’ll go into a folder called Quarantined
If an active (non-archived) job with the same name as a job in the file already exists, that job will be updated with the information provided in the file. If a job does not exist or was previously archived it will be created and if a job exists in MachineMetrics but is not present in the jobs file, it will be archived.
Troubleshooting
The Job Importer logs information to the Windows Event Viewer in the “Applications and Services” section in the “MachineMetrics” Log. If you are having issues with the Job Importer, retrieve the logs from the Windows Event Viewer by using the “Save All Events As...” button and change the “Save as Type” to “csv” and include the file with your support request email.
If you see errors relating to the service not being able to access the folder specified or that the folder doesn't exist, it may not have proper access rights to the network location. If the network location requires authentication you will need to run the service as a user that has permission to read from this folder. You can do this from the Windows Services list. Find the MachineMetrics Job Imported in the list, right-click on it, click on Properties, and then the “Log On” tab. Select “This account” and enter the user name as “Domain\UserName” and the password with confirmation. Click “OK” and restart the service to run as the new user.
Import Jobs by Script
If you’re not using a Windows computer or would like to disable the auto archive functionality of the Job Importer Service, using a script to import your jobs might be the correct choice. Auto archiving will archive all jobs not listed on the latest .CSV you're uploading.
Important: To use this method, it is recommended you have some familiarity with scripts or contact your IT to assist.
To import your jobs, we’ll be using an API request, specifically, the /jobs/import
endpoint of our production APIs. More documentation on this endpoint here.
Linux & macOS
- Open a text editor (BBEdit, terminal editor such as nano or vim, etc) and paste the following cURL
curl --location --request POST 'https://api.machinemetrics.com/jobs/import?fileFormat=mm' \
--header 'Authorization: Bearer APIKEYHERE' \
--form 'csvFile=@FILEPATHHERE'
- Replace the text
APIKEYHERE
with the API key that you generated in the section above - Replace the text
FILEPATHHERE
with the location of the .CSV file you want to import - Save the file as a .sh
- Automate the running of your script through whatever means you prefer, the most common method being a Cron Job. For information on using Cron, take a look at this article
Note: You may need to expand the permissions of your script or your target CSV! Running the command chmod +x filename.sh
will make your script executable.
Windows
We’ve used a slightly different cURL script for the Windows version. This version creates a log.txt file you can use in case something isn’t working with your import.
- Open a text editor such as (notepad, notepad++, etc) and paste the following cURL
@echo off
set url=https://api.machinemetrics.com/jobs/import?fileFormat=mm
set apiKey=APIKEYHERE
set filePath=Users/Cullen/Documents/export.csv
curl --location -X POST -F "csvFile=@/%filePath%" --url %url% -H "Authorization: Bearer %apikey%" -i > log.txt
- Replace the text
APIKEYHERE
with the API key that you generated in the section above - Replace the filePath with the location of the .CSV file you want to import. We've left a file path there as an example
- Save the file as a .bat
- Automate the running of your batch file however you prefer. One method is the Windows Task Scheduler. See this article for some information on how to set that up
If you have any questions, feel free to reach out to our Technical Services Team at support@machinemetrics.com
Comments
0 comments
Article is closed for comments.