PODetail API

Hi All,

Does anyone have any JSON example to create a line on a PO via API?

Anything I try I get a lovely error

{
    "odata.error": {
        "code": "",
        "message": {
            "lang": "en-US",
            "value": "The request is invalid."
        },
        "innererror": {
            "message": "entity : An error has occurred.\r\n",
            "type": "",
            "stacktrace": ""
        }
    }
}

I just want to create a line with

  • PartNum
  • Line Price
  • Qty

All the best,
Aaron.

“The request is invalid” usually means the json is incorrect, maybe some bracket is missing.

Can you paste what you are sending and also which endpoing exactly are you using?

1 Like

Hi

This is my JSON and the end point I am using is

{
  "Company": "TEAGLE",
  "OpenLine": true,
  "VoidLine": true,
  "PONUM": 766711,
  "QtyOption": "Our",
  "PartNum": "SC1100",
  "OrderQty": 20
}
Erp.BO.POSvc/PODetails

Kind regards,
Aaron.

So I got it adding the line but I cannot seem to get it to add the price

{
   "Company":"TEAGLE",
   "OpenLine":true,
   "VoidLine": false,
   "PONUM":766711,
   "POLine":0, 
   "QtyOption":"Our",
   "PartNum":"SC1100",
   "CalcOurQty": "20",
   "CalcVendQty": "20",
   "IUM": "EA",
   "Taxable": true,
   "PUM": "EA"
}

I have tried DocUnitCost, UnitCost, SrcUnitCost, DocScrUnitCost etc.

They don’t seem to fill in unit cost for that part. Any ideas?

Have you done a trace to follow along with the UI? You should be able to see where it gets added and through what method.

I worked out the dream JSON

{
   "Company":"TEAGLE",
   "OpenLine":true,
   "VoidLine": false,
   "PONUM":766711,
   "POLine":0, 
   "PartNum":"SC1100",
   "QtyOption": "Our",
   "DocScrUnitCost": "20.30",
   "ScrUnitCost": "20.30",
   "CalcOurQty": "20",
   "CalcVendQty": "20",
   "IUM": "EA",
   "Taxable": true,
   "PUM": "EA"
}

You need ScrUnitCost and DocScrUnitCost

2 Likes

Yeah, nice. Just as a suggestion for future reference/testing/development, I’ve often found it easiest and best to:

  1. Create the transaction/record in the system manually via the standard UI
  2. Get/extract the record via the REST API to your preferred output (i.e. JSON to a notepad application or to an Excel or CSV format)
  3. Delete the record in the system manually via the standard UI
  4. Import the extracted record data via the REST API and confirm creation etc.
  5. Then repeat steps 3 and 4 above with a modified dataset until it meets requirements

As by doing so I’ve found it a lot easier to find/figure out any fields/data that may also need to be populated for the desired outcomes. While keeping in mind that in many cases, via the standard UIs, unexpected data can often be directly automatically populated at the UI level or via OnChange method calls during normal entry - which can be easily identified by re-extracting the imported record during iterations and comparing it to the extracted data from the record(s) created via manual entry via the UI.

Ideally, it’s generally desirable/best to confirm that the data imported via the REST APIs and integrations matches that of what it would have been if entered manually by a user via the standard user interfaces for functionality, consistency, and support reasons and the above process makes it easy to do so.

With Tracing. Always be tracing…

Trace Helper Utility for Epicor ERP 10 - ERP 10 - Epicor User Help Forum (epiusers.help)

2 Likes

Yeah, good point. Definitely one of the best methods to find/detect variances and learn how and what the UI is calling. Along with a good comparison tool like WinMerge (free) or Beyond Compare to compare the request and response datasets.