REST BOGet ResponseData but not able to access the fields

I am working on some utilities to automate some processes. I am wanting to return a list of Companies from Epicor, so I figured I would use the Erp.BO.CompanySvc/GetList method. I can get the data back in the ResponseData, but I have not figured out how to access it. The examples I saw in the forums showed a couple of different methods, but none have yet worked. I am using the EpicorRestAPI nuget package also.

                var response = EpicorRest.BoGet("Erp.BO.CompanySvc", "GetList", dic, callContext);

                if (!response.IsErrorResponse)
                    foreach (var item in response.ResponseData)
                        tempList.Add(item.CompanyList.Company); // I have tried a bunch of different permutations of this and not gotten any of them to work

The data being returned looks right, I am just not sure how to parse it out.

Return Data:
{“returnObj”: {\r\n “CompanyList”: [\r\n {\r\n “Company”: “ASPN”,\r\n “Name”: “***** ASPN - 20211117 - TEST *****”,\r\n “Address1”: “123 W 1st St”,\r\n “City”: “Duluth”,\r\n “State”: “MN”,\r\n “Zip”: “55807”,\r\n “PhoneNum”: “(123) 456-1111”,\r\n “SysRowID”: “9bfb9b35-a9cf-478e-a7e9-64dc801a6485”,\r\n “RowMod”: “”\r\n },\r\n {\r\n “Company”: “TMC”,

and repeat like that until it gives me all 40 companies

Any thoughts?

@Paul_Millsaps You need to lookup json deserialize. Here is a thread the might help.

I have only done a couple of rest projects, but I did a BAQ to get back my data, so I controlled the content.

Here’s the documentation for that library with examples of how to access the data

1 Like

I am using v2. I know there was a documentation page with some examples, but I do not remember where they were located.

I had used this structure below, but it did not return anything when I tried it.

//The code above returns an EpicorResponseObject (response) below are some ways to use it

// Allows you get an individual property from your response using the dynamic object

It gave a null error:
‘Cannot perform runtime binding on a null reference’

What I found after further research, is the OData methods will work and give data like the example, but not the custom methods. I’ll get into those next I think. Below is what I came up with for a working code segment

CallContextHeader callContext = new CallContextHeader();

                var response = EpicorRest.BoGet("Erp.BO.CompanySvc", "Companies", dic, callContext);

                if (!response.IsErrorResponse)
                    var company = response.ResponseData.value[0].Company1;
                    var limit = response.ResponseData.value.Count;
                    for (int i = 0; i < limit; i++)