API Key invalid immediately after generation

Here I go again with another (more than likely) silly problem.

I am working with Function maintenance for the first time, and have prepared a function to be tested. The library has been promoted to production, the function has been tied to an OnClick() event, and the necessary parameters have been set.

I generated an API key with no specific Access scope, and an expire date of many years out. This key was then plugged in to the function attached to the OnClick().

When I activate the OnClick() event, and debug in the F12 menu, I get this:
image

I tried testing the function within the REST API Help page, using the same API key as the header, with the same result.

Any ideas? I’m guessing there is something simple I’ve missed while learning this process.
Thanks in advance

Unless you copied it wrong, then no, that should work.

If you’re talking about the App Studio property that says API-Key required, it is not. Leave it blank.

If you call it outside of Kinetic, via Postman, etc., then it IS required.

He’s also calling it via Swagger, with the same result.

I’m gonna ask a dumb question, because I’ve made it myself…

Did you make your key in Pilot, and test in Production… or vice versa ? It happens :rofl:

2 Likes

Our company is in the process of moving from 10.700 to Kinetic, so I’ve been working on customization uplift. With that, I haven’t even logged in to the live environment yet.

I tried a couple different times making a key in the Pilot client, and the Pilot web version, both with no success.

It made a key that doesn’t work, or didn’t make a key?

It makes a key that doesn’t work. Epicor gives no information in the error, just a “Something went wrong, please contact your system administrator.”

Make a key, copy it and go to Swagger.

Navigate to
https://YourEnvironment/api/help/v2/odata/Erp.BO.ABCCodeSvc/index.html

Choose the first option GET /{currentCompany}/Erp.BO.ABCCodeSvc/
Choose try it out.
Enter your company id, and key.
Click Execute,

What happens?

It executes, cache-control is private, and the server is blank in the response headers. Not sure if this is normal or not.

Did it give you a json return?

This is what was in the Server Response body, the odata context looked correct above this.

image

Then your API Key is fine.

The error is in your function, or the way you are calling it.

If you would like, we can probably help with that.

Sorry for the delayed reply, I feel quite silly.

After debugging for a bit, the problem was I didn’t pass anything to the “plant” field when updating JobHead.

Huge facepalm moment, but the function is working properly now.

That’s me.

Every

Damn

Day.

1 Like