Solved

Subcontracts API

  • 25 October 2023
  • 11 replies
  • 97 views

Userlevel 2
Badge

Hey team, need some assistance with creating subcontracts via rest api. Looks like subcontracts are just a type of the PO (which im able to create via api without a problem), but if I pass PO type as Subcontract Im getting an error :

 \"exceptionMessage\": \"Cannot generate the next number for the  sequence.\",

 

Anybody had any luck creating Subcontracts via API?

C# library Acumatica.Default_22_200_001.Model
PurchaseOrder model

icon

Best answer by vramkrishna26 27 October 2023, 19:40

View original

11 replies

Userlevel 5
Badge

@dpruckus - I suggest extending the endpoint to a new name via the 22.200.001 version.  Then I would look at the segmented keys ID for subcontracts -> numbering ID and see if you have a numbering id which is generating the number sequences populated.  If not you should create one and it should resolve that error via the API.

Userlevel 2
Badge

@dpruckus- I suggest extending the endpoint to a new name via the 22.200.001 version.  Then I would look at the segmented keys ID for subcontracts -> numbering ID and see if you have a numbering id which is generating the number sequences populated.  If not you should create one and it should resolve that error via the API.

Hey Steven. Thanks for your reply. Can you elaborate a little bit more? I have already extended my endpoint but I cant seem to find anything about subcontracts there. Thanks!

 

 

Userlevel 7
Badge +4

@dpruckus 

Could you please share some screenshots of what you trying to achieve and what is the behavior via UI(screen ID, some example)

Userlevel 2
Badge

@dpruckus

Could you please share some screenshots of what you trying to achieve and what is the behavior via UI(screen ID, some example)

So instead of PO, Im trying to create Subcontract.

 

It works fine on UI, but via API it gives me the above error if I use POModel and set Type = “Subcontract”.

POs are created fine via API if Type = “Normal” or Type=’Project Drop-Ship’ It seems to me that Subcontracts are the same POs (same module) but Im still not sure how to set PO type to be Subcontract.

 

 

Userlevel 7
Badge +4

@dpruckus UI actions used to populate data/grid are not (I believe) supported via API.

Userlevel 2
Badge

@dpruckus UI actions used to populate data/grid are not (I believe) supported via API.

 

Im sorry, what? That doesn't make any sense, sorry. 

Userlevel 7
Badge +4

@dpruckus 

from the screenshot, “CREATE SUBCONTRACT” seems to an action.

Last time I checked, populating grid via UI Actions was not supported via APIs.

Userlevel 2
Badge

What is it different from Create PO?

Userlevel 7
Badge +4

@dpruckus are you able to execute Create PO action from API.

I checked the default endpoint definition but did not see any component relating to Create PO action:

 

Userlevel 2

Hi @dpruckus 

I was able to create a sample Subcontract.

The solution was to extend the web service endpoint to expose the SubContract's screen and map the fields accordingly. 

 


 

You can follow the blog post  on extending the WebService Enpoint.

https://www.acumatica.com/blog/extending-acumatica-web-service-endpoints/



Perform a Put request using the url below:

API Request URL: - https://URL/InstanceName/entity/APISamplesEndpoint/22.200.001/Subcontracts

Request Body:
{
    "Approved": {
        "value": true
    },
    "Details": [
        {
            "Account": {
                "value": "XXXX"
            },
            "Amount": {
                "value": 100.0000
            }
        }
    ]
    "SubcontractNbr": {
        "value": "NEW"
    },
    "ExpiresOn": {},
    "Hold": {
        "value": true
    },
    "LineTotal": {
        "value": 100.0000
    },
    "Location": {
        "value": "MAIN"
    },
    "Project": {
        "value": "X"
    },
    "RetainageTotal": {
        "value": 0.0000
    },
    "Status": {
        "value": "On Hold"
    },
    "SubcontractTotal": {
        "value": 112.0000
    },
    "TaxTotal": {
        "value": 12.0000
    },
    "VATExemptTotal": {
        "value": 0.0000
    },
    "VATTaxableTotal": {
        "value": 100.0000
    },
    "Vendor": {
        "value": "XXXX"
    }
}
 

 

Userlevel 2
Badge

Hi @dpruckus 

I was able to create a sample Subcontract.

The solution was to extend the web service endpoint to expose the SubContract's screen and map the fields accordingly. 

 


 

You can follow the blog post  on extending the WebService Enpoint.

https://www.acumatica.com/blog/extending-acumatica-web-service-endpoints/



Perform a Put request using the url below:

API Request URL: - https://URL/InstanceName/entity/APISamplesEndpoint/22.200.001/Subcontracts

Request Body:
{
    "Approved": {
        "value": true
    },
    "Details": [
        {
            "Account": {
                "value": "XXXX"
            },
            "Amount": {
                "value": 100.0000
            }
        }
    ]
    "SubcontractNbr": {
        "value": "NEW"
    },
    "ExpiresOn": {},
    "Hold": {
        "value": true
    },
    "LineTotal": {
        "value": 100.0000
    },
    "Location": {
        "value": "MAIN"
    },
    "Project": {
        "value": "X"
    },
    "RetainageTotal": {
        "value": 0.0000
    },
    "Status": {
        "value": "On Hold"
    },
    "SubcontractTotal": {
        "value": 112.0000
    },
    "TaxTotal": {
        "value": 12.0000
    },
    "VATExemptTotal": {
        "value": 0.0000
    },
    "VATTaxableTotal": {
        "value": 100.0000
    },
    "Vendor": {
        "value": "XXXX"
    }
}
 

 

Thats exactly what I need! I think it should work now. Thanks

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved