Creating a Quote with REST

I’m investigating the swagger documentation for QuoteSvc. My trace log for a new quote shows that I need to do a GetNewQuoteHed call, then an Update after that.

I went into the swagger > Bo.QuoteSvc/GetNewQuoteHed section and found the example. I copy pasted it into my POSTMAN and tried to run it, but I’m getting a something went wrong Server 500 error.

I can run other REST requests inside my POSTMAN so it must be something with this particular service. Is there some way to find out what the error was? Maybe a log somewhere?

you basically need to find out the bare bones minimum number of fields that need to be sent… AND you can figure this out by using Rest, as it will reject the post message if you are missing data. I just did something similar yesterday on Sales order Header addition… We found that in order to add a sales order with Sales.UpdateExt process from Rest, we needed Customer number, Billto Number, Shipto Number Company ID, Terms code… once we populated those fields and called UpdateExt, it worked, and created a new sales order, returning back to us the sales order number that was created. The last thing we figured out was that we needed the Shipto number… we had everything else, and it told us that was missing. So… it was trial and error, but only took a half dozen tries.

I think I accidentally edited my first post instead of replied, anyhow I’m looking for a way to find any logs for “Something Went Wrong” server 500 errors. Are those logged anywhere? Maybe IIS? I wouldn’t even know where to look for that though.

I found the IIS logs, but they’re not really detailed. I found my failed POSTMAN requests along with the POSTMAN requests for other items that successed (status: 200)

You can enable REST trace flag on your app server. Then you can open the server log and search for the RESTAPI tags. They will have more detailed info about the error. The flag is in the AppServer.config file.

1 Like

Thank you. I found the flag and uncommented it on the TRAIN. When you say Server Log do you mean the same file as in my screenshot? I don’t see any RESTAPI info in there after enabling it. Maybe I need to recycle IIS?

You can probably skip the GetNew and go straight for the jugular (POST QUOTES which calles UpdateExt).

You will need to pass all key fields, and possibly some others. A RowMod of “A” for one. You can test this out without REST by using the BL Tester. Once you get the UpdateExt creating a new record, you can migrate it to REST.

Don’t listen to @Chris_Conn he is nutz! LoL Follow the trace do yourself a favor,… specially for Quotes

1 Like

UpdateExt does not require RowMod, it goes to Db, searches for item by key and if it is not found, it will add it

1 Like

I understand you have done a GetNew and an Update. I don’t know if you have done a trace…as suggested multiple times by different member.

Here are my calls using the custom methods.

image

and pay attention to the response body returned versus what need to be sent to the method.

I’m trying to test the REST service with POSTMAN and I get an error:
here is the screencapture: postman-test.mp4

So I’m wondering why doesn’t it work right out of the box? Is there some other configuration that needs to happen? (I’m running this against the TRAIN slot so it’s okay if many quotes are created while testing.)

Looks like you are copying an example response and trying to send it. Instead grab the example parameter below it and to the right.

I did this recently. Creating the quote header was fairly straightforward with a POST:
server/api/v1/Erp.BO.QuoteSvc/Quotes

{
    "Company": CompanyID,
    "QuoteNum":0,
    "CustomerCustID":CustID,
    "CustNum":CustNum,
    "ShipToCustNum":CustNum,
    "PrcConNum":ConNum,
    "ConName":ConName,
    "ECCComment":"Generated from website by " + UserEmail
    "MktgCampaignID": "DEFAULT",
    "MktgEvntSeq": 1,
    "TerritoryID":TerritoryID,
}

The response data will have the quote number you just created.

The quote lines were similar but a little more involved because for some reason the price and discount is not calculated or applied properly when the record is created:

server/api/v1/Erp.BO.QuoteSvc/QuoteDtls

{
  "Company": CompanyID,
  "QuoteNum":QuoteNum,
  "QuoteLine":0,
  "PartNum":"Web",
  "LineDesc":PartDescription,
  "CustNum":CustNum,
  "CustomerCustID":CustID,
  "OrderQty":"1",
  "SellingExpectedQty":"1",
  "DocExpUnitPrice": Price,
  "ProdCode":ProdGroup
}

Then do a PATCH with the Price again - for some reason it doesn’t take on the new record.

{
  "DocExpUnitPrice": Price
}

Then get the discount and externally calculate the discount amount and do a PATCH to apply this amount:

{
  "DocDspDiscount":Discount
}
2 Likes

@smason as @Chris_Conn said you are passing in the response as the payload for the request. I am not trying to be rude here but it seems you are trying to jump in with both feet on something fairly advanced that you don’t yet have the understanding of.

Perhaps baby steps are in order first? gotta learn to walk before you can run! Creating a quote on REST or even outside of rest is fairly complex.
I would recommend getting some base understanding off the REST API concept in general and then perhaps use a smaller business object to get your feet wet? For my training I usually use ABCCode to start with using Custom Methods and understanding the mechanics.

Just my 2 cents, I think if you just jump right in you are going to end up making some key mistakes in the process which will require you to rewrite the thing in the end. As they say you are going to have to pay for it at some point, in the beginning, middle or the end.

Checkout the REST Novel
as well as the many other REST Related posts on the site.

Read the Epicor Help in regards to REST that is VERY VERY complete and pretty through
Read up on SWAGER.IO and oData

https://epicweb.epicor.com/Education/OnlineHelpFeatureSummary/Epicor%20ERP%2010/10.2.200/Help/enu/Standard/REST/RestImplementationHeader.html

https://epicweb.epicor.com/doc/Docs/Epicor10_RESTServices_v1_102400.pdf#search=REST
Etc.

4 Likes

I don’t mean to be rude neither. I’ve just posted you to be careful with the response body and the payload (method) of the request .

He re is the image I’ve sent you. Do you see the difference?

The right portion of the image is what the method needs and the left portion is a copy-paste of a previous response. Don’t do that.

1 Like

I don’t think anyone is being rude. Thank you and everyone for your feedback. I totally agree that baby-steps are required. I know I’m just starting out on my REST journey. My understanding is “patchy” I know some stuff but then there are really simple things that I struggle with.

It seems like it doesn’t need to be complicated. It can be made simple with good documentation and I think Epicor’s technical documentation is not great. When I get this working I plan to make a tutorial video of how to use POSTMAN to create a quote so future users like me can benefit from going through step by step, here is a trace log, here is the POSTMAN app, here is what you type here, etc.

1 Like

I really hope that was an intentional REST joke

3 Likes

Ooooh, Dad Joke approved! :medal_sports::trophy:

2 Likes

After recently becoming a dad, these jokes just come naturally to me now

2 Likes

You’ll see others make it even less complicated (like @josecgomez) and instead of putting the business logic in your REST calls using the QuoteSvc, others use an updateable BAQ and use the BAQSvc instead. Why? Now all of your business logic is in one place and you won’t be coping code to every client and having to have to change all that code if there is a change in the service. Also, the BAQAvc is one of the most stable and will not likely change much from version to version.

Food for thought…

Mark W.

4 Likes