Rest API determining mandatory fields

Hi All,
I am new to the Rest API and am currently able to retrieve/add/update customers after some tinkering.

General question: I was wondering how to determine the required fields when attempting to make an API call to a service? Specifically, I am trying to create a quote using the Erp.BO.QuoteSvc service. I am testing in Swagger and cannot get a quote header generated. All the parameters show as optional so I am not sure what I am missing. The error I am getting back in Swagger is shown below. Just not sure how to tell what it’s looking for.

{
“HttpStatus”: 400,
“ReasonPhrase”: “REST API Exception”,
“ErrorMessage”: “Reference is required.”,
“ErrorType”: “Ice.Common.BusinessObjectException”,
“ErrorDetails”: [
{
“Message”: “Reference is required.”,
“Type”: “Error”,
“Table”: “QuoteHed”,
“Program”: “Epicor.RESTApi.dll”,
“Method”: “ThrowUpdateExtException”,
“ColumnNumber”: 17,
“LineNumber”: 40
}
]
}

I am sending in values for: Company, CustNum, CustomerCustID, PrcConNum, ConName, ShipToCustNum, QuoteNum, QuoteComment, SalesRepName, MktgCampaignID, MktgEvntSeq, TerritoryID, ECCComment

Primarily concerned with creating a Quote Header and Quote Detail lines at this time.

Thank you in advance for your help

I haven’t found a good way to know exactly which fields are required. If you are a regular Epicor user or admin, it is usually intuitive. Sometimes, like in this case, it is guess and check.

It is telling you that you need to include the Reference field. That is surprising, because it’s not required in the client. Maybe Epicor is the one requiring it, or maybe there is a BPM in place at your company that requires the users to enter a value in that field.

I struggled with quotes but finally got it working with a JSON payload that looks like this for quote head. We don’t actually create quote lines in our workflow with REST. Our users wanted to be able to copy paste a blob of text and have that be the entire quote because they work mostly from email. And since we don’t create orders from quotes the way Epicor intends we that doesn’t bother us.

Here is an example of the JSON payload that we got working:

{
“Company”: “SD”,
“QuoteNum”:0,
“CustomerCustID”: “0020350”,
“CustNum”:2,
“ShipToCustNum”:2,
“PrcConNum”:0,
“ConName”: “”,
“ECCComment”: “TEST QUOTE FROM POSTMAN”,
“MktgCampaignID”: “DEFAULT”,
“InsideSalesRep_c”: “SMASON”,
“MktgEvntSeq”: 1,
“TerritoryID”: “HBHouse”,
“ShipToContactName_c”: “Scott”,
“ShipToPhone_c”: “555-555-5555”,
“ShipToEmail_c”: “smason@example.com”,
“FollowUpDate”: “2019-07-07”,
“Quoted”: true,
“DateQuoted” : “2019-06-20”,
“ExpirationDate” : “2016-09-22”,
“QuoteJrText_c”: “text in UDF field xyz xyz”,
“ShipToCustomerName_c”: “Some extra text goes here”,
“ChangedBy” : “manager”,
“Reference” : “NSTACH”
}

Sent as a POST against this REST endpoint: [[your-server-address]] /v1/Erp.BO.QuoteSvc/Quotes

As far as figuring our what is mandatory and what isn’t I haven’t found a good way beyond testing with POSTMAN. Yes, some things are unituitive and it’s like why do you need “market campaign” like couldn’t Epicor just default some of this stuff?

Anyway I think you know the process start with the Swagger payload and then start removing stuff until it breaks and try again, POSTMAN is a great tool for that in case you’re not using it. I think the prevailing idea is you want to be able to pass the payload with the fewest fields possible to get it working and POSTMAN lets you rapidly play with the JSON payload to figure out what that final JSON should look like.

1 Like

Postman also has a cool feature to convert the call into a programming language if you are ever developing something external that’s calling the Epicor REST API. It’s a good starting point at least.

Thank you so much for all the help. I should have realized that the error response was very clear that it was missing the ‘Reference’ field. I read that wrong thinking it was more of a generic response. Also wanted to make sure there was area where it listed the mandatory fields for each service call.

1 Like