Rest - Allowing access to context header

Hey guys, I am working on an application that uses the Rest services and I am now trying to handle if the user places a BPM on a method what it will do in the front end code. For an example i have placed a show message on the ‘GetList’ method of VendorSvc. This will just show simple ‘This is a test message’ whenever that method is called.

Now the issue I am encountering is that the rest service does not pass in its response body, only on the response header, therefore the application cannot access this information.

We see it in the response header. We see the bpm I placed on the method is in that data, but because it is not within the body the code cannot use it.

My question is has anyone else been able to get the information from the response header being passed inside the response body?

If anyone is interested in the future times. The default web.config itself does not give access to the context header variable. Therefore the javascript could not access the info. To counter this you can modify your web.config as follows.

If you have issues getting access from local host you can chuck this in the app settings to open up the origin.
image

2 Likes

The dataset should be within this function

Example in code.
image
Gives this.
image

Hey Nicholas,

Thanks for posting this here. I didn’t realize that we had not opened up use of the context header when dealing with cross-origin web apps. I’m writing up a ticket to change this default so it’s easier for others in the future. Thanks!

Hey mate, thanks for letting me know about this. Look forward to the update, we had written a little script that adds these modifications as a workaround, one less deployment step hopefully soon! :wink::+1:

Just for anyone else that comes across this to give a little more context. The release of Epicor we are running is 10.2.100.8.


I found this modification needed to be added to 10.1.500, 10.1.600 versions of epicor when activating the Rest service in the admin console. Without modifications only cross origin request on can access Cache-Control and Content-Type. (ContextHeader is in my screenshot due to previous modifications)