Contractor Assigned Cost Centers always returns empty array
Forum rules
- Check the documentation first. Before posting questions, please check the documentation to ensure it doesn't already cover what you need.
- No spam. All automated messages, advertisements, and links to competitor websites will be deleted immediately.
- Post in relevant sub-forums only. Messages posted in the wrong topic area will be removed and placed in the correct sub-forum by moderators.
- Respect other users. No flaming or abusing fellow forum members. Users who continue to post inflammatory, abusive comments will be deleted from the forum after two warnings are issued by moderators.
- Harassment. No threats or harassment of other users will be tolerated. Any instance of threatening or harassing behavior is grounds for deletion from the forums.
- Adult content. No profanity or pornography is allowed. Posts containing adult material will be deleted.
- Bandwidth. All images and signatures must be 500 x 500 pixels or smaller. Posts containing over-sized images and signatures will be removed.
- Illegal content. No re-posting of copyrighted materials or other illegal content is allowed. Any posts containing illegal content or copyrighted materials will be deleted.
Contractor Assigned Cost Centers always returns empty array
I am trying to retrieve all cost centers assigned to a contractor.
Im using the end point {{baseUrl}}/api/v1.0/companies/:companyID/contractors/:contractorID
The response always returms an empty array of cost centers even if there are ones assigned ie. AssignedCostCenters is always [].
"DateCreated": "2024-04-03T11:05:31+11:00",
"DateModified": "2024-07-17T14:52:06+10:00",
"Archived": false,
"AssignedCostCenters": [],
"Zones": [],
"DefaultZone": {},
"DefaultCompany": {
"ID": 2,
But when i login to SimPro gui.. the contractor does indeed have cost centers. I have tried adding/removing some via the guy and then calling API again.. but can never get anything returned other than an empty array.
build is https://mpeelec.simprosuite.com
contractor is in company 3... contractorID 1596
As a side note... Zone's is also empty all the time in bodies returned from the API.. but this contractor has every state assigned to them in the GUI.
Please advise whats going on
Im using the end point {{baseUrl}}/api/v1.0/companies/:companyID/contractors/:contractorID
The response always returms an empty array of cost centers even if there are ones assigned ie. AssignedCostCenters is always [].
"DateCreated": "2024-04-03T11:05:31+11:00",
"DateModified": "2024-07-17T14:52:06+10:00",
"Archived": false,
"AssignedCostCenters": [],
"Zones": [],
"DefaultZone": {},
"DefaultCompany": {
"ID": 2,
But when i login to SimPro gui.. the contractor does indeed have cost centers. I have tried adding/removing some via the guy and then calling API again.. but can never get anything returned other than an empty array.
build is https://mpeelec.simprosuite.com
contractor is in company 3... contractorID 1596
As a side note... Zone's is also empty all the time in bodies returned from the API.. but this contractor has every state assigned to them in the GUI.
Please advise whats going on
Re: Contractor Assigned Cost Centers always returns empty array
I have managed to solve the mystery. In my eyes.. its a bug, but you be the judge.
You need to send the request ensuring the company ID in the URL is set to the 'DefaultCompany.ID' value of the contractor.
ie the contractor exists in all 3 sub-companies (2,3 and 38)... but its DefaultCompany is 2.
If i send the request asking for all contractor details as companyID 3... it returns the contractor.. but most of the arrays are empty. As soon as i ask for the same contractor details with CompanyID as 2 in the URL.. it populates the arrays.
If it can find the contractor and return it... it should returning it properly and completly... not half baked just because the companyID does not align with the contractors DefaultCompany.ID
You need to send the request ensuring the company ID in the URL is set to the 'DefaultCompany.ID' value of the contractor.
ie the contractor exists in all 3 sub-companies (2,3 and 38)... but its DefaultCompany is 2.
If i send the request asking for all contractor details as companyID 3... it returns the contractor.. but most of the arrays are empty. As soon as i ask for the same contractor details with CompanyID as 2 in the URL.. it populates the arrays.
If it can find the contractor and return it... it should returning it properly and completly... not half baked just because the companyID does not align with the contractors DefaultCompany.ID
-
SimproAPITeam
- Posts: 831
- Joined: Wed May 01, 2024 2:31 am
Re: Contractor Assigned Cost Centers always returns empty array
Hi jp85,
We've done some investigation, it seems like it's behaving as expected similarly to Simpro Premium, Contractor 1596 only has assigned cost centres on CompanyID 2, Thats why you are only getting values when pointing to CompanyID 2,
It's likely because the company does not have shared setup so each company will have their own Cost Centres, Eg. Cost Centres from CompanyID 2 wont be available in CompanyID 3 or 38.
Hope that helps!
We've done some investigation, it seems like it's behaving as expected similarly to Simpro Premium, Contractor 1596 only has assigned cost centres on CompanyID 2, Thats why you are only getting values when pointing to CompanyID 2,
It's likely because the company does not have shared setup so each company will have their own Cost Centres, Eg. Cost Centres from CompanyID 2 wont be available in CompanyID 3 or 38.
Hope that helps!
Simpro API Team | Simpro Software Group
Re: Contractor Assigned Cost Centers always returns empty array
Hi again.
So i have now added all cost centers to the contractor from each of the 3 companies. When i retrieve the contactor via postman.. the array is empty for every company.
It seems that as soon as i have cost centers for more than 1 company assigned to the contractor... it always returns an empty array no matter which company i try to access the contractor through.
As soon as i remove all cost centers from all companies EXCEPT keep one companies cost centers... the array returns for that specific company ok. IE having 2 companies cost centers allocated to a contactor at the same time stops the API from returning any cost centers for any of the companies.
Here is my script adding the cost centers
[2024-07-31T12:34:48.415] [DEBUG] SimProAPICaller - About to update contractor '1596' with payload {"AssignedCostCenters":[384,247,246,341,15,14,11,248,250,20,145,344,8,245,343,22,303,21,243,60,6,383,5,388,379,380,386,385,282,387,307,244,10,17,13]} for company 2
[2024-07-31T12:34:48.415] [DEBUG] SimProAPICaller - End point is https://mpeelec.simprosuite.com/api/v1. ... ctors/1596
[2024-07-31T12:34:48.994] [DEBUG] SimProAPICaller - Response status is 204
[2024-07-31T12:34:48.994] [DEBUG] SimProAPICaller - About to update contractor '1596' with payload {"AssignedCostCenters":[44,55,56,57,53,59,54,208]} for company 3
[2024-07-31T12:34:48.995] [DEBUG] SimProAPICaller - End point is https://mpeelec.simprosuite.com/api/v1. ... ctors/1596
[2024-07-31T12:34:49.378] [DEBUG] SimProAPICaller - Response status is 204
[2024-07-31T12:34:49.379] [DEBUG] SimProAPICaller - About to update contractor '1596' with payload {"AssignedCostCenters":[382,312,308,342,309]} for company 38
[2024-07-31T12:34:49.380] [DEBUG] SimProAPICaller - End point is https://mpeelec.simprosuite.com/api/v1. ... ctors/1596
[2024-07-31T12:34:50.388] [DEBUG] SimProAPICaller - Response status is 204
And now the log in the contractor from the GUI shows
Updated Cost Centres from "" to ", , , , "
Updated Cost Centres from "" to ", , , , , , , "
Updated Cost Centres from "" to ", , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , "
Now no cost centers show via the gui for any company and nothing returns from the API if i ask for its cost centers.
via postman for this contractor i added cost center 384 as company 2. it shows up in the GUI. I then add cost center 44 for company 3. No cost centers for the contractor show up in the gui any more for company 2.. only the cost center for comany 3 when i switch to that company.
If i then send a patch request as company 2 trying to add both 384,44 to the contractor i get an error... because cost center 44 is not part of company 3.
If i do a similar thing via the GUI.. the log actually shows the cost center names being added collectivly eg.
"Updated Cost Centres from "Air Circuit Breakers (ACB)" to "Air Circuit Breakers (ACB), Rectification - Non Billable""
rather than just empty quotes as per the above examples ive given.
Ide really appreciate someone to call/contact me so i can demo this problem to you if its not clean via this message
So i have now added all cost centers to the contractor from each of the 3 companies. When i retrieve the contactor via postman.. the array is empty for every company.
It seems that as soon as i have cost centers for more than 1 company assigned to the contractor... it always returns an empty array no matter which company i try to access the contractor through.
As soon as i remove all cost centers from all companies EXCEPT keep one companies cost centers... the array returns for that specific company ok. IE having 2 companies cost centers allocated to a contactor at the same time stops the API from returning any cost centers for any of the companies.
Here is my script adding the cost centers
[2024-07-31T12:34:48.415] [DEBUG] SimProAPICaller - About to update contractor '1596' with payload {"AssignedCostCenters":[384,247,246,341,15,14,11,248,250,20,145,344,8,245,343,22,303,21,243,60,6,383,5,388,379,380,386,385,282,387,307,244,10,17,13]} for company 2
[2024-07-31T12:34:48.415] [DEBUG] SimProAPICaller - End point is https://mpeelec.simprosuite.com/api/v1. ... ctors/1596
[2024-07-31T12:34:48.994] [DEBUG] SimProAPICaller - Response status is 204
[2024-07-31T12:34:48.994] [DEBUG] SimProAPICaller - About to update contractor '1596' with payload {"AssignedCostCenters":[44,55,56,57,53,59,54,208]} for company 3
[2024-07-31T12:34:48.995] [DEBUG] SimProAPICaller - End point is https://mpeelec.simprosuite.com/api/v1. ... ctors/1596
[2024-07-31T12:34:49.378] [DEBUG] SimProAPICaller - Response status is 204
[2024-07-31T12:34:49.379] [DEBUG] SimProAPICaller - About to update contractor '1596' with payload {"AssignedCostCenters":[382,312,308,342,309]} for company 38
[2024-07-31T12:34:49.380] [DEBUG] SimProAPICaller - End point is https://mpeelec.simprosuite.com/api/v1. ... ctors/1596
[2024-07-31T12:34:50.388] [DEBUG] SimProAPICaller - Response status is 204
And now the log in the contractor from the GUI shows
Updated Cost Centres from "" to ", , , , "
Updated Cost Centres from "" to ", , , , , , , "
Updated Cost Centres from "" to ", , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , "
Now no cost centers show via the gui for any company and nothing returns from the API if i ask for its cost centers.
via postman for this contractor i added cost center 384 as company 2. it shows up in the GUI. I then add cost center 44 for company 3. No cost centers for the contractor show up in the gui any more for company 2.. only the cost center for comany 3 when i switch to that company.
If i then send a patch request as company 2 trying to add both 384,44 to the contractor i get an error... because cost center 44 is not part of company 3.
If i do a similar thing via the GUI.. the log actually shows the cost center names being added collectivly eg.
"Updated Cost Centres from "Air Circuit Breakers (ACB)" to "Air Circuit Breakers (ACB), Rectification - Non Billable""
rather than just empty quotes as per the above examples ive given.
Ide really appreciate someone to call/contact me so i can demo this problem to you if its not clean via this message
-
SimproAPITeam
- Posts: 831
- Joined: Wed May 01, 2024 2:31 am
Re: Contractor Assigned Cost Centers always returns empty array
Hi jp85,
Thanks for the explanation, i believe I understand what you are saying, when the contractor is assigned to cost centres on multiple companies, the result is returning empty [],
We've raised an internal ticket for this and we'll address this issue as soon as we can.
Thanks for the explanation, i believe I understand what you are saying, when the contractor is assigned to cost centres on multiple companies, the result is returning empty [],
We've raised an internal ticket for this and we'll address this issue as soon as we can.
Simpro API Team | Simpro Software Group
Re: Contractor Assigned Cost Centers always returns empty array
Thanks. Please also add to your internal ticket that there does not seem to be a way to add cost centers from different companies to a contractor via the API. The last API call containing the cost centers for a given company is the only cost centers that survive.
ie... if i add cost center X for company 1 and then try to add cost center Y for company 2... cost center X disapears for company 1 from both API and GUI. The logs kind of reflect this because they show it went from X to Y... rather than saying it went from X to X,Y
If however you do these actions via the GUI.. it does indeed preserve the other companies cost centers and shows originally X.. now X, Y.
There does not seem to be a way to add cost centers for multiple companies via the API.. any 1 call for a given company replaces all cost centers associated to all the other companies rather than just replacing the cost centers for the company the API call is being raised against.
ie... if i add cost center X for company 1 and then try to add cost center Y for company 2... cost center X disapears for company 1 from both API and GUI. The logs kind of reflect this because they show it went from X to Y... rather than saying it went from X to X,Y
If however you do these actions via the GUI.. it does indeed preserve the other companies cost centers and shows originally X.. now X, Y.
There does not seem to be a way to add cost centers for multiple companies via the API.. any 1 call for a given company replaces all cost centers associated to all the other companies rather than just replacing the cost centers for the company the API call is being raised against.
-
SimproAPITeam
- Posts: 831
- Joined: Wed May 01, 2024 2:31 am
Re: Contractor Assigned Cost Centers always returns empty array
thanks for more info, i've updated the ticket.
Simpro API Team | Simpro Software Group
Re: Contractor Assigned Cost Centers always returns empty array
Just to enable me to set some expectations with my customer.
What is the process and time frames in which bugs like this are addressed?
How will i be informed of the release schedule for a fix and how will i be informed when the fix is deployed.
Currently this defect is restricting the ability for my customer to go live with the product ive built for them since they need to manage contractor cost centers pro grammatically.
Thanks
JP
What is the process and time frames in which bugs like this are addressed?
How will i be informed of the release schedule for a fix and how will i be informed when the fix is deployed.
Currently this defect is restricting the ability for my customer to go live with the product ive built for them since they need to manage contractor cost centers pro grammatically.
Thanks
JP
-
SimproAPITeam
- Posts: 831
- Joined: Wed May 01, 2024 2:31 am
Re: Contractor Assigned Cost Centers always returns empty array
Hey jp85,
One of our devs is working on this issue at the moment and the API release normally goes out with Simpro releases which happens every two weeks. But we could also patch release prioritised issues. We'll send you a message once this is released.
One of our devs is working on this issue at the moment and the API release normally goes out with Simpro releases which happens every two weeks. But we could also patch release prioritised issues. We'll send you a message once this is released.
Simpro API Team | Simpro Software Group
Re: Contractor Assigned Cost Centers always returns empty array
Hi,
Looking for an update on this defect please. Is there a scheduled resolution time?
Regards
James
Looking for an update on this defect please. Is there a scheduled resolution time?
Regards
James
DEVELOPER CENTER