Rest Api Help

Hello,

I’m trying to call Inspection Receipt via REST API simply by using swagger UI. Here is how:

curl -X GET --header ‘Accept: text/plain’ ‘https://epicor102test/ERP102100/api/v1/Erp.BO.InspProcessingSvc/InspRcpts

For all inspection service calls (GET method) I’m getting the following exception:

{"HttpStatus":500,"ReasonPhrase":"REST Api Exception","ErrorMessage":"Parameter count mismatch.","ErrorType":"System.Reflection.TargetParameterCountException"}

Please help.

Welcome to the group @agholian!

It’s best to start a new topic instead of adding onto a Solved one.

REST API clarifications needed:

I’m trying to call Inspection Receipt via REST API simply by using swagger UI. Here is how:

curl -X GET --header ‘Accept: text/plain’ ‘https://epicor102test/ERP102100/api/v1/Erp.BO.InspProcessingSvc/InspRcpts’

For all inspection service calls (GET method) I’m getting the following exception:

{"HttpStatus":500,"ReasonPhrase":"REST Api Exception","ErrorMessage":"Parameter count mismatch.","ErrorType":"System.Reflection.TargetParameterCountException"}

On the Swagger page, what are you providing in the Input parameters? It’s a fairly complicated one.

I merged the posts together for you guys. Welcome @agholian

2 Likes

Hi Mark,

Thanks for clarification.

There is no parameter required, it is supposed to return all entities. but I can set $select, $filter, $orderby, $top and $skip. I have tried setting $top to 1 which I’ve got the same results.

As do I. So I changed to the Custom methods instead of OData to see if I could do a GetRows and that’s where I see the complex input parameters. Since receipts are a “subset” of Inspection Processing, I wonder if we need to make another call first.

What does the Trace show?

Hello Mark,

I could get it to work using the GetRows custom method:

{
  "plOperation": false,
  "plMaterial": false,
  "plInventory": false,
  "plFirstArt": false,
  "plReceipt": true,
  "plRMA": false,
  "pcInspectorID": "",
  "pcCutOffDate": "",
  "whereClauseNonConf": "",
  "whereClauseFirstArt": "",
  "whereClauseRcvDtl": "",
  "whereClauseRMA": "",
  "whereClauseSelectedSerialNumbers": "",
  "whereClauseSNFormat": "",
  "whereClauseInspProcList": "<PONum> >= (88217)",
  "sortBy": "PONum",
  "pageSize": 250,
  "absolutePage": 0
}

but on my backend, I generated C# code using the service metadata, which I’m having the same issue with.

Hey Amin,
To clarify, you are able to use the GetRows method with a specific whereClauseInspProcList value to return the appropriate data via the Swagger UI page, however you are unable to return the data correctly using the same endpoint and same payload via your c# calling application?

1 Like

Have you tried Epicor Functions? Simplify your REST call and do the lookup in the Function.

1 Like

4 Likes

That is correct. Visual Studio auto generated the C# object proxies using the service metadata. Here is my C# code:

InspProcessingSvc.Erp.RestApi EpicorRestApi = new InspProcessingSvc.Erp.RestApi(new Uri("https://epicor102test.coaxtech.local/ERP102100/api/v1/Erp.BO.InspProcessingSvc/"));

List<InspRcpt> InspRcpts;

InspRcpts = EpicorRestApi.InspRcpts.Where(x => x.PONum == 88217).ToList();

I’m using OData to do mass receive operation on my C# backend which works fine.

I don’t know must about your EpicorRestAPI object, but that looks like it’s using linq over the dataset to retrieve the record, but I’m not 100% sure that is the same as calling the API method like you did in Swagger. It’s unfortunately a little too abstracted for me to be able to speak to it, but that’s definitely something to look into

I had this working using Swagger UI custom method (GetRows) by setting the following parameters:

{
  "plOperation": false,
  "plMaterial": false,
  "plInventory": false,
  "plFirstArt": false,
  "plReceipt": true,
  "plRMA": false,
  "pcInspectorID": "",
  "pcCutOffDate": "",
  "whereClauseNonConf": "",
  "whereClauseFirstArt": "",
  "whereClauseRcvDtl": "",
  "whereClauseRMA": "",
  "whereClauseSelectedSerialNumbers": "",
  "whereClauseSNFormat": "",
  "whereClauseInspProcList": "<PONum> >= (88217)",
  "sortBy": "PONum",
  "pageSize": 250,
  "absolutePage": 0
}

Do you know how these should be set using swagger UI OData ?

The real question is what you’re doing in the c# app. Which call is your EpicorRestApi object actually making behind the scenes?
Try it with a regular http client first to work out the plumbing

1 Like

Please forget about the C#, I’m trying to use Epicor’s Swagger UI OData to get the list of received items that require inspection by calling:

curl -X GET --header 'Accept: text/plain' 'https://epicor102test/ERP102100/api/v1/Erp.BO.InspProcessingSvc/InspRcpts'

Thanks

Oh I see what you’re saying. I am getting the 500 with the OData call in postman/swagger too, however the GetRows service does work fine. OData call is supposed to implement GetRows, but I too am unable to see that working. Is there a reason you need to use the OData Methods?

1 Like

Hello,

We are doing integration with a part traceability application that is going to be used in our receiving stations, that’s the reason why we are using C#/TypeScript to call Inspection Processing APIs. Using custom method I could retrieve inspection pending materials in C#.

Right now I’m having trouble with calling “InspectReceipt” custom method. before calling the method, I’m calling the following methods (1-3) in order (following the Epicor’s trace log):

  1. “AssignInspectorReceipt” (executes OK)
  2. “OnChangePassedQty” (executes OK)
  3. “OnChangeFailedQty” (executes OK)
  4. “InspectReceipt” (Returns with “Object reference not set to an instance of an object” exception)

Here is the exception received from Epicor’s backend as the result of calling custom method in step 4:

{"HttpStatus":500,"ReasonPhrase":"REST Api Exception","ErrorMessage":"Object reference not set to an instance of an object.","ErrorType":"System.NullReferenceException"}

Our Epicor version is 10.2