Page 1 of 1

POST new job

Posted: Mon Apr 03, 2023 10:12 am
by Dazwah
Hello,

I have a few questions for when I post a new job;

POST /api/v1.0/companies/{companyID}/jobs/

The api doc states that "technicians" should be an integer, should it be an array of integers?
Also, how do I set a custom field in the same payload?

Last question is, how do I link a cost centre to the associated job? Does that have to be done after a job is created?

Re: POST new job

Posted: Mon Apr 03, 2023 11:04 am
by BlessingLinys
The "technicians" field should be an array of integers, even though the API documentation states it as an integer. You can provide an array of technician IDs to this field.

To set a custom field in the same payload, you can include it as a key-value pair in the payload data. For example, if the custom field is named "custom_field", you can include it like this:

{
"title": "Job Title",
"description": "Job Description",
"technicians": [1, 2, 3],
"custom_field": "Custom Field Value"
}

To link a cost centre to the associated job, you can provide the cost centre ID as a field in the payload data. For example:
{
"title": "Job Title",
"description": "Job Description",
"technicians": [1, 2, 3],
"cost_center": 12345
}

This will link the job to the cost centre with ID 12345. This can be done while creating the job itself, and does not need to be done after the job is created.

Re: POST new job

Posted: Mon Apr 03, 2023 10:17 pm
by Dazwah
Thank you. Do you know where the cost centre is in the API? Want to know if its cost_center, cost_centre, costCentre.

With the custom field, is it purely based on the name of the custom field? I can see they have IDs

Re: POST new job

Posted: Tue Apr 04, 2023 10:50 pm
by Sindre
Hi Dazwah,
For the setup of the actual cost centers, please see this link:
https://developer.simprogroup.com/apido ... st-Centers

For managaing a cost center on a job please see this link:
https://developer.simprogroup.com/apido ... 0b4eb3c8db

Regards

Re: POST new job

Posted: Tue Apr 04, 2023 11:55 pm
by Dazwah
Hi Sindre,

What I mean is, I cannot find in the "job" (api /api/v1.0/companies/{companyID}/jobs/)
where anything mentions cost_center, just wondering if its hidden elsewhere in the API documentation.

Im also trying to add attachments, can this just be done like the following?

{
"title": "Job Title",
"description": "Job Description",
"technicians": [1, 2, 3],
"cost_center": 12345,
"attachment":{
"file":{
"Filename":"myfilename.doc",
"Base64Data" :"mydata..."
}
}
}

Re: POST new job

Posted: Wed Apr 05, 2023 12:42 am
by Sindre
Hi,
The cost centre info is in a nested structure under jobs, sections and cost centre.

You can use the parameter ?display=all on a job to see more details. ]

Code: Select all

api/v1.0/companies/0/jobs/{jobID}?display=all
Read more on subresources here:
https://developer.simprogroup.com/apido ... place-data

To get an overview of cost centres you can also use this endpoint which has a link to the nested structure:

Code: Select all

/api/v1.0/companies/{companyID}/jobCostCenters/
Regards

Re: POST new job

Posted: Wed Apr 05, 2023 4:48 am
by Sindre
The attachments will have to be added on the job level and not sections/cost centres.
https://developer.simprogroup.com/apido ... 6ee72946b0

Re: POST new job

Posted: Wed Apr 05, 2023 4:59 am
by Dazwah
To set a custom field in the same payload, you can include it as a key-value pair in the payload data. For example, if the custom field is named "custom_field", you can include it like this:

{
"title": "Job Title",
"description": "Job Description",
"technicians": [1, 2, 3],
"custom_field": "Custom Field Value"
}

Can you please verify that this is the correct way to set a custom field in the payload?

Re: POST new job

Posted: Wed Apr 05, 2023 6:07 am
by Sindre
Hi,
Custom fields don't support POST request so I don't think you can add it like described.

You need to know the ID of the custom field you want to patch. So follow this endpoint:
https://developer.simprogroup.com/apido ... f9d625d754

Code: Select all

/api/v1.0/companies/{companyID}/jobs/{jobID}/customFields/{customFieldID}
Regards