Skip to main content
New Participant
Oct 2, 2025 2:07 PM UTC

AddWorkOrderCosts API issue with Storeroom/Source

I am calling an API to add material to a work order.

 

My call:

https://MyCWServer.org/Staging/Services/Ams/MaterialCost/AddWorkOrderCosts?data={"WorkOrderId": "123123","WorkOrderSid":123123,"MaterialSids":[232],"Units":2.0000,"Source":1}&token=<CWTOKEN>

 

My results:

{"Value":[],"Status":1,"Message":"User does not have permissions to 1 storeroom.","ErrorMessages":[{"Storeroom":"1","MessageType":2,"Code":27,"Service":"MaterialCostService","Name":"InvalidStoreroom","DebugDetails":"User does not have permissions to 1 storeroom.","DisplayText":"User does not have permissions to 1 storeroom.","InnerMessage":{"Storeroom":"1","ItemId":0,"MessageType":2,"Code":6,"Service":"StoreroomService","Name":"StoreroomNotAuthorized","DebugDetails":"","DisplayText":"User does not have permissions to 1 storeroom.","InnerMessage":null}}],"WarningMessages":[],"SuccessMessages":[]}

 

I have verified that the 232 does exist in stockroom 1 and the API caller has temporarily been given full system admin rights.

 

My only thought is the Source since is improperly set up in the JSON.

 

 

 

    7 replies

    Known Participant
    Oct 2, 2025 4:11 PM UTC

    @paul malabad? The Source parameter is a String field, not numeric, so the value should be in quotes. The valid list of values for Source should line up with values in the STOREDOMAINSTORE table STOREROOM field, which come from the PWCODE table CODE field where CODETYPE = STORERM. You can query that via the APIs using the /Ams/Storeroom/Storeroom or /Ams/Codes/ByCodeType calls, which will return things from the CodeDesc Data Type. Unless you named a Storeroom Code "1", you're not passing the correct value.

    Translate
    New Participant
    Oct 2, 2025 4:11 PM UTC

    @steven sushka? Thanks, that moves me closer to a correct API call. I fixed the code to put Quotes around the warehouse code. We do use a number for the STOREROOM field to match the third party system. "1" CODE is "Central Stores" DESCRIPTION in the PWCODE table.

     

    However, I get the same error.

    I have assigned roles as a System Admin and a Central Stores Admin.

    I made them a domain admin for the storerooms.

    I made them an administrator for CityWorks.

    I verified Storeroom full Permissions on the employee as well as WorkOrder full permissions.

    Unless there is another spot to give individual store room permissions, I am running low on ideas.

    Translate
    Known Participant
    Oct 2, 2025 4:11 PM UTC

    @steven sushka? Thanks, that moves me closer to a correct API call. I fixed the code to put Quotes around the warehouse code. We do use a number for the STOREROOM field to match the third party system. "1" CODE is "Central Stores" DESCRIPTION in the PWCODE table.

     

    However, I get the same error.

    I have assigned roles as a System Admin and a Central Stores Admin.

    I made them a domain admin for the storerooms.

    I made them an administrator for CityWorks.

    I verified Storeroom full Permissions on the employee as well as WorkOrder full permissions.

    Unless there is another spot to give individual store room permissions, I am running low on ideas.

    @paul malabad? This call worked for me in a 23.11 site as a post with the token passed in the body with the data. Starting in Cityworks 23.x, you can no longer pass a token via a URL.

     

    Ams/MaterialCost/AddWorkOrderCosts?data={"WorkOrderId":"136011","MaterialSids":[1623],"Units":2.0000,"Source":"MAIN"}

     

    Taking a second look at your call, 1) you don't need to use both "WorkOrderId" and "WorkOrderSId" - just one or the other, and 2) there was space in your call after "WorkOrderId": before the "123123".

     

    Otherwise, what license(s) are assigned to that user? If that info doesn't help, you'll need to log a support case.

     

    Steven

    Translate
    Known Participant
    Oct 2, 2025 4:11 PM UTC

    @steven sushka? Thanks, that moves me closer to a correct API call. I fixed the code to put Quotes around the warehouse code. We do use a number for the STOREROOM field to match the third party system. "1" CODE is "Central Stores" DESCRIPTION in the PWCODE table.

     

    However, I get the same error.

    I have assigned roles as a System Admin and a Central Stores Admin.

    I made them a domain admin for the storerooms.

    I made them an administrator for CityWorks.

    I verified Storeroom full Permissions on the employee as well as WorkOrder full permissions.

    Unless there is another spot to give individual store room permissions, I am running low on ideas.

    @paul malabad? P.S. Is that user also in a Storeroom Group assigned to Storeroom 1 - Central Stores, and that Group has the appropriate permissions on Storeroom 1? You might have covered that when you said "I verified Storeroom full Permissions on the employee", but I want to make sure.

    Translate
    Known Participant
    Oct 2, 2025 4:11 PM UTC

    @steven sushka? Thanks, that moves me closer to a correct API call. I fixed the code to put Quotes around the warehouse code. We do use a number for the STOREROOM field to match the third party system. "1" CODE is "Central Stores" DESCRIPTION in the PWCODE table.

     

    However, I get the same error.

    I have assigned roles as a System Admin and a Central Stores Admin.

    I made them a domain admin for the storerooms.

    I made them an administrator for CityWorks.

    I verified Storeroom full Permissions on the employee as well as WorkOrder full permissions.

    Unless there is another spot to give individual store room permissions, I am running low on ideas.

    @paul malabad? P.S.S. Can you log into the UI as that API user and add that same material from the same storeroom to the WO in question?

     

    The AMS/MaterialCost web service requires the WO API Extended license for integrations and typically does not require a UI-level license, such as AMS Edit +, that would be used to log in to the UI. A Storeroom license is only needed if interacting with materials from within the Storeroom app, so that's not required in the UI if you're just on a WO adding a material.

     

    Anyway, if you only have the WO API Extended license assigned to the API user, you could temporarily add an AMS Edit+ license to the API user to log in to Respond or Office to try and add the material to the WO from within the WO and verify all the configuration and permissions are correct. If that works, then things should work the same with the API call.

    Translate
    New Participant
    Oct 2, 2025 4:11 PM UTC

    @paul malabad? P.S. Is that user also in a Storeroom Group assigned to Storeroom 1 - Central Stores, and that Group has the appropriate permissions on Storeroom 1? You might have covered that when you said "I verified Storeroom full Permissions on the employee", but I want to make sure.

    This was it. I had the person as a Domain Admin under ADMIN...Storeroom...Domains, but neglected to look at Stockroom...Config. Groups. It is always the mundane details...

    Translate
    Known Participant
    Oct 2, 2025 4:11 PM UTC

    @paul malabad? P.S. Is that user also in a Storeroom Group assigned to Storeroom 1 - Central Stores, and that Group has the appropriate permissions on Storeroom 1? You might have covered that when you said "I verified Storeroom full Permissions on the employee", but I want to make sure.

    Awesome! I'm glad that helped.

    Translate