Calling REST API Patch from an ECM Datalink

I have been setting up some data links using the ERP REST Api to create PO’s and PO Lines. This is part of a PO Requisition workflow and working nicely. But the next thing I wanted to do was set the GLCode.

I have created the entry in the CallDefinitions.json file and I am using a PATCH Request and I can test it fine, but becuase it is a Patch request the PONum, Line, Rel, and COA are in the URL.

So the question is, how do I pass the parameters into the URL? Below show the entry for this particular request as you can see at the moment I have entered some specific values but these need to be replaced with parameters.

I’ve done a lot of work with the datalinks from within the ECM UI, but I’m not familiar with the method you are describing. I know there is an ‘add on’ that I can get from Epicor that allows us to write our own custom Datalinks - is that what you are using?

If so:
I’m sorry that I can’t be of more help. And I do not know of anyone here who has/uses it currently.

I know that I, @gpayne, and a few others would absolutely LOVE to see this in action. Perhaps you might consider posting a quick walk-through write-up with a few screen shots?

1 Like

EPICOR provided a WebDatalink dll that enable us to make the REST API calls. Happy to share some more details, I will put something together. It does work really well, it’s just that in this scenario it has fallen short. I have asked them the question also and I am waiting for a response I am hoping that it is just a case of them further educating me. The issue is that this is not documented so only learned by training from the ECM Consultant.

1 Like

Cool - we talked to them about this at Insights this year, but no one else has pulled the trigger yet. Anything you can do would be helpful - thanks! :slight_smile:

@steveh So back to your original question. Are the parameters in the workflow being passed to the json and then the url and you need to set them to real values rather than hardcoded?

You can do a normal sql datalink to get the data from Epicor and set the values.

Another approach and why I want the rest dll is to be able to change data in a bpm and send it back to ECM. You could update the GLCode in Epicor and send it back.

Can you call the method GetNewPORelTGLC instead and pass the data in the json with this utility?

Well yes. The question here was because for this particular issue I was using a Patch request which involved parameters in the URL I cannot work out how to pass a parameter in this way. I could however pass the whole URL as a parameter so solution number one in this case was to create a field group and use a standard SQL Datalink to build the url for each release and then pass the URL into the REST request. This works perfectly. That said, and given that I have in the end had to do this extra SQL Lookup, I could just get the sysrowID’s for each line and use UpdateEXT as a POST instead which would also solve the problem.

So ideally it would be good to know if I could pass in parameters to the URL but due to the versatility of the toolset I have bee able to work around it.

It is good that it has a way around, but you might get more rest centric answers if you reposted as a rest issue and not in the ECM category. I can’t imagine there are not people here who know the answer.

1 Like

Not sure if you tried but I’ve been testing API in ECM and by putting parameters in the Data Link, I’m able to reference them in the URL like that and it works

image

Could you share more on this?

I’m curious as to how you have the connection set up and what you have in the datalink.

For datalinks, there are typically one of two main methods for extracting data using the REST API: 1) The URL has the specific parameters which are required 2) The URL has a filter which allows you to declare the parameters you want to use.

Specific Parameters
“Name”: “BuyerLookUp”,
“Url”: “/api/v1/Erp.BO.POSvc/POes(‘@Company’,@PONum)”

Filtered Parameters
“Name”: “BuyerLookUp”,
“Url”: “/api/v1/Erp.BO.POSvc/POes?%24filter=Company eq ‘@Company’ and PONum eq @PONum

This allows you to dynamically populate the inputs (Company and PONum) to extract the outputs you choose. The outputs available are found in the schema for the REST API call you use.

1 Like

There is a couple of files that EPICOR supplied that go in the datalinks directory on the server.

The REST calls are defined in a JSON File also in this folder.

There is a section that defines the access token:

And then you add entries for the calls that you wish to make, the simple example here creates a requisition header

In ECM You can then set up the DataLink. Note the connection references the WebDataLink.dll and the parameters match those defined in the JSON file:

Where did you get the .dll?
I thought this was built in the newer versions of DocStar?

It may well be included now, I think we were quite early adopters of this.
We were supplied it by the consultant who helped with our install.
If you don’t have the necessary files, perhaps try requesting it via support?

You’re correct in saying it is built in in the later versions of ECM. In the last screenshot you can see the “JSON Web Service” which removes the need for the .dll to be on any machine.

So what is throwing me off really is that there is a call definition for the DataLink Connection and a Call Definition for the DataLink itself.

Is this redundant?

The top section is for the token datalink and then the bottom section is for all of the datalinks that will use that token datalink.

1 Like

Do you mind sharing what your structure looks like?

Nevermind. It’s the DataLink that is the issue.

The example they stub in was not helpful to me, but @utaylor got me going and I have this below for sending parameters to a baq and getting back results.

[
    {
        "URL": "https://server.domain.com/EpicorInstance/api/v1/BaqSvc/COMP01-GetJobs/?PackNum=@PackNum",
        "Method": "Get",
        "AuthScheme": "@TokenType",
        "AuthParameter": "@AccessToken",
        "Body": null,
        "CollectionPath": "value",
        "WSHeaders": [
            {
                "Key": "CallSettings",
                "Value": "{PackNum: @PackNum}"
            }
        ],
        "Columns": [
            {
                "Name": "ShipDtl_PackNum",
                "Path": "ShipDtl_PackNum",
                "ChainOutput": null
            },
            {
                "Name": "Calculated_Job",
                "Path": "Calculated_Job",
                "ChainOutput": null
            }
        ],
        "ContentType": "application/json",
        "Parser": 0,
        "EscapeParameters": false,
        "XMLNameSpaces": null
    }
]
2 Likes