Creating a Quote with REST

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

I approve this message. I much prefer keeping my logic in a UBAQ, then calling that via REST.

Like I said, much smarter people than I… Epicor’s CRM app is done this way too FWIW.

Thank you, you’ve helped me move along farther than I was. I used the ODATA method: server/api/v1/Erp.BO.QuoteSvc/Quotes

The one thing that’s giving me a problem is that I can make quote headers in one company with POSTMAN but not with another company. The error log keeps saying invalid customer or invalid territory, even though I change all the correct criteria and those do in fact live at those companies.

I’m wondering if it is something to do with the authentication. I’m using the manager account while testing…

Edit: Yes it was authentication in POSTMAN. I changed to a different account that was specific to the other company and I was able to create a quote header record in there too.

I have found that Multi-Company users with v1 version of REST tend to connect to the last company logged in. Single company users are fine. I have to pass company ID in on the URI with unpredictable results.

Also, you may have to make sure your workforce in the other companies allows you to access those territories or you have View All Territories checked.

I successfully used POSTMAN to create a QuoteHed record.

Here is the video tutorial (no sound) for anyone that was in my position: Create QuoteHed with POSTMAN (8.23 MB)

It’s actually not super difficult. I was able to get it done with the help from this forum so thank you to everyone that commented. :grinning: Maybe this will help some other newbie like me.

2 Likes

To switch companies you need to use the CallSettingsHeader

There are days I want to make a rest novel sequel. Then I have 15 meetings in a day and would like to see my wife :rofl:
I appreciate all the support you folks are giving to the new convert and welcome to the domain @smason
Maybe I’ll make a flavor for what’s shipping in vNext.
#SafeHarbor
200w

4 Likes

I thought so… did you end up seeing anything? @josecgomez it is the app server log file where the restapi trace is stored, right?