Calling REST API Patch from an ECM Datalink

Hi, attempting to communicate ECM datalink with the WebService option. Duplicated the BAQ call example. I pasted the sample syntax into the top Datalink connection, modified url for our server, created a company wide shared BAQ called Comp01-GetJobs on ShipDtl with a PackNum parameter match and display fields including ShipDtl_PackNum and Calculated_Job. Tried using api_key as AuthScheme and a valid api key for AuthParamenter. Got back a empty box labeled Test Data.
Is my AuthScheme incorrect ? Any help please ?
Have been struggling to make a connection that returns data for a number of days… Any help is greatly appreciated…

The top Call Definitions is the logon and is the same for all of that servers rest calls.

@vleveris @utaylor I can’t remember, but I think the AuthParameter is the logon:password for the rest user base64 encoded??

[
    {
        "Url": "https://server.domain.com/Instance/TokenResource.svc/",
        "Method": "Post",
        "AuthScheme": "Basic",
        "AuthParameter": "cH******Qx",
        "WSHeaders": [
            {
                "Key": "a",
                "Value": "b"
            }
        ],
        "Columns": [
            {
                "Name": "AccessToken",
                "Path": "AccessToken",
                "ChainOutput": "@AccessToken"
            },
            {
                "Name": "TokenType",
                "Path": "TokenType",
                "ChainOutput": "@TokenType"
            },
            {
                "Name": "ExpiresIn",
                "Path": "ExpiresIn"
            },
            {
                "Name": "RefreshToken",
                "Path": "RefreshToken"
            }
        ]
    }
]

1 Like

I think you actually figured that out and taught me and I believe I’ve seen @josecgomez talk about it too… not exactly in this context but some other post out there. Pretty sure you used something to show me how to encode it in the way it needed it…

We used a base64 encoding site. I thought that was not right, but I decoded my token and it was user:password.

I agree. user name:password I used https://www.base64decode.org/ to create the authparameter.

Also, depending on your set u, it may be worth checking the Access Scope for the user as well

1 Like

Would definitely agree that the top Datalink connection will need the corresponding hashed AuthParameter to be the “username:password” encoded in base64.

For the bottom Datalink where your BAQ is, it would seem to me that you’re using a v2 API call instead of v1 based on the fact you are required to enter an API key. In the REST area, you can switch the calls from v2 to v1 using the dropdown option on the top left of the call you’re in.

Screenshots would help to troubleshoot things, but it’s entirely understandable if you can’t share for privacy or any other reason.

1 Like

Thanks for that. I will apply the recommendations and share the results…

1 Like

Baby Drinking GIF by reactionseditor

I have used Base64 converter for username:password and inserted into AuthParameter, AuthScheme set to Basic. Used manager user. Hardcoded values into JSON as am trying to make it as basic a request as possible. Put everything in the Top DataLink connection box. Bottom DataLink Call settings empty. Changed the url to v1 of REST , which works when put into a Browser, returns records wo need for API Key. Still get empty Test Data box on Test Live. see below. Here is the full JSON call. Url works in browser, retuns BAQ data. Any ideas please …

[
    {
        "URL": "https://erp.xxxxxxx.com/kineticxx/api/v1/BaqSvc/COMP01-GetJobs/?PackNum=10",
        "Method": "Get",
        "AuthScheme": "Basic",
        "AuthParameter": "bWFuxxxxxhZ2Vy",
        "Body": null,
        "CollectionPath": "value",
        "WSHeaders": [
            {
                "Key": "CallSettings",
                "Value": "{PackNum: 10}"
            }
        ],
        "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
    }
]

Can you just run a normal BAQ and make sure it’s all working? No parameters?

Also make sure you can run that service from the swagger page using the URL you’re attempting to use with the ?parameter value you’re attempting to use.

MAybe you’ve done this already, so ignore me if you have :sweat_smile:

1 Like

I pass the parameter in the URL. ?PackNum=10… That works in the browser. Just talked to someone that said the Top Connection box is to get a token , the Bottom Call Settings box is to call the method. Does that sound true ? Do I NEED to split this up ? thanks…

Max, when you find any documentation on this let me know :sweat_smile:

Kinda sad that we have to guess around at this.

Max, I’m just saying, run it without a parameter.

If you still get nothing back then there’s something wrong with the way you defined the JSON body that it’s expecting back. The “collection path” as I understand it from reading absolutely no documentation and getting through this from previous examples written by someone else and trial and error.

1 Like

Try modifying your JSON for the collection path

    "CollectionPath": "value",
    "WSHeaders": [
      {
        "Key": "CallSettings",
        "Value": "{Company: \"@Company\", Address1: \"@Address1\"}"
      }
],
 "CollectionPath": "",
    	"Columns": [
      {
        "Name": "Company",
        "Path": "Company"
      },
{
        "Name": "Address1",
        "Path": "Address1"
      },
{
        "Name": "VendorID",
        "Path": "VendorID"
      },
{
        "Name": "VendorNum",
        "Path": "VendorNum"
      }
    ]
  },

notice that you’re missing the ,“CollectionPath”:“”,Columns part

Max. Do you know there’s a log for your datalink/rest call right? Like you can see the log of what happened and whether there were errors? Have you looked at the log?

I believe your URL needs some changes.

Try this:

“URL”: “https://erp.xxxxxxx.com/kineticxx/api/v1/BaqSvc/COMP01-GetJobs/?$filter=PackNum eq 10”,

You can also add in a parameter to make this dynamic like this:

“URL”: “https://erp.xxxxxxx.com/kineticxx/api/v1/BaqSvc/COMP01-GetJobs/?$filter=PackNum eq @PackNum”,

With that you would then add that parameter to the Datalink and you can test all of this by entering in a test value.

Lastly, you may want to remove the “encoded” AuthParameter from your post as it is easily decoded. I know you have not provided the Epicor address, but figured I’d mention it anyways.

2 Likes

Huge thanks victor. I learned from y’all on this. Do you know if there is a whitepaper on the setup of all this? Or is it just info you’re being fed from ECM epicor staff?

Not as far as I am aware of. Fortunately, I have colleagues like @BScanlan and @swilliasc111, along with some others, who have been a tremendous help in troubleshooting as well as resolving issues through some trial and error. We are all a bit obsessed with figuring out how all of this works and how far we can push it lol

2 Likes