Calling WepApi For App from outside the App.

Feb 11, 2016 at 6:34 PM
Hi,

I'm trying to call the WebAPI for an App from another page which doesn't have the app on the page. But the server throws an error which doesn't tell me much.

Does 2sxc care about the Referer and TabId in the Request Header when calling the WebApi function? Because these two are different to what they would be in a page containing the App.

I'm including the js file /DesktopModules/ToSIC_SexyContent/Js/2sxc.api.js and then calling $2sxc(#TheModuleID).webApi.get("Controller/Function")

Thanks in adnvace
Coordinator
Feb 12, 2016 at 8:31 AM
In general various mechanisms will check if you are coming from the module you're claiming to use (this in DNN security framework), and if it's a 2sxc-module, etc. (for context, to know what data is to be used).

I'm sure you can somehow get it to work, but it would be easier to create a simple view in your app which doesn't show anything and include it on the page where you plan to use the data, and make your calls through that app. Because then you have an app, you have a view, 2sxc knows everything it needs for context, and the rest of your JS etc. can be outside of that app (or running inside it, whatever you prefer).
Feb 12, 2016 at 4:26 PM
Thanks - I created a blank template as part of the App included that, replaced the module filters with Entity Type filters so each app access the same data and it's working a charm.