Lookupcache not working as expected in Apigee - apigee

I am calling a oauth call and saving the clientid of the call using populate cache and assigning that clientid to variable via lookupcache and consuming that variable in subsequent calls for different endpoints its working fine but when i make another oauth call with different client the immediate lookupcache variable value is showing as null until i make another APIendpoint call how to resolve this .The expecation is lookupcache variable is assigned as soon as populate cache is populated

Related

In Katalon Studio how to store element value in Global Variable from Web Service Response and need to pass in another Web Service Request or Header

I am configuring the web service in Katalon Studio. I have to take element value from web service response and stored it in global variable and the same element has to be sent in next web service request or header part.
Whenever i hit this web service, i will get unique values. The same values need to be updated in global variable and have to sent current value in next service.
OAUTH - In below example i need to store access_token 7 its value in Global Variable and need to use it across.
"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzQ2OTY0NzQsInVzZXJfbmFtZSI6ImJlYXN0dGVzdDQiLCJhdXRob3JpdGllcyI6WyJST0xFX0JFQVNUX0JPX0lUIiwiUk9MRV9CRUFTVF9DQVBfQURNSU4iLCJST0xFX0JFQVNUX1NVUEVSVVNFUiIsIlJPTEVfQkVBU1RfRlJBVURfVkVMT0NJVFlfQ0hFQ0siLCJST0xFX0JFQVNUX0JBQ0tfT0ZGSUNFIiwiUk9MRV9CRUFTVF9DQVBfTU9OSVRPUiIsIlJPTEVfQkVBU1RfRlJPTlRfT0ZGSUNFIl0sImp0aSI6ImU1YWVmNDk1LTAwN2YtNGM4NS04MmZiLWYzZjEzNjNlNTgzNiIsImNsaWVudF9pZCI6Ik9hdXRoLVRydXN0ZWQtQ2xpZW50Iiwic2NvcGUiOlsicmVhZCIsIndyaXRlIl19.hD3BXKJbo2sTkEhQAYxUi7CDU45-ZtZWjjpO99-21McrvK74Ffh0uIImFTE71JI0wjwUWZ1zM28rZ7pQfQB9TLOeUW1bImtFDMaHIg_NvfWXLNCQe8lREjCv-LhpSkKksUyBU85A-Q8T4az0VQyKGs0AfHvc2gTrEWuoJGQpDfePz3l_10fJnEqC5arev-vIF1zeMijHXUWQd-AGKr_PLn2S8iPOpkBAiNmz1SDTDBZe1jdpVfYSC1RJQAbzOWGpL0ia7TAzBPpEpn6XV3emoIWIpFTJY0CNavQvEL9fc-D8nPmwF4q_Tnm2LnqbtCIlqk2SbFU5bdSmtIZfl5atxA",
Transaction Id: In below example i need to store transactionID and its value in global variable and need to use it across.
{
"transactionID":"09610123112519543357"
}

Using connection service based by params

I have many services extending MsSQLAbstractService class, each for single database. For my application I need to connect to the proper database based on a parameter in the request.
How can I pass such a parameter and make the SQL class use the service I want?
I created my own SQL class, when passing the ID manually everything works, but I need to pass it from the request. How can I pass that param from request to SQL class?
Extracting the parameter
Depends on your requirements:
Service call from front end: Probably you could register a #Replace-Annotated ServiceTunnelServlet-subclass and extract it from the request there.
Alternatively, there also is a thread-local that keeps the request for service tunnel calls: IHttpServletRoundtrip.CURRENT_HTTP_SERVLET_REQUEST. If you can easily extract it from the URL or header: great
REST call to your backend: Extract it in the appropriate Servlet
Storing the parameter
You can wrap method calls in a ServerRunContext, and pass properties along that you can extract at other locations! See the ServerRunContext#withProperty(String,String) method.
You can create a new Context using the ServerRunContexts helper methods.
Using it
This part you already seem to have solved: You can use a single registered Service or appropriate #Order annotation to get the request and then dispatch them to the proper service based on the ID that you stored in the ServerRunContext.

How can you tell if you're within a method call in Meteor?

I have this setup where when collection.update() is called from the client, a before-update hook gets triggered in the server (using matb33:meteor-collection-hooks). This trigger then uses Meteor.user().someData to get some data off the user. This works fine.
The problem is sometimes I need to update from the server, with no user in context. So I get a Meteor.userId can only be invoked in method calls error.
I'd like to know how to properly detect if the update hook is being run outside the context of a method call or publish function, when there is no user.

Session state access in Web API across domains

I have a ASP.Net API implementation, where to store and access the data / variables across consecutive calls, I am using a session state object as shown below and it can be successfully accessed in the multiple calls to separate calls by a browser:
// Access the current session object
var blSession = HttpContext.Current.Session;
// create the BL object using the user id
BL accessBL = new BL(userID);
// Store the Bl object in the session object dictionary
blSession["UserBL"] = accessBL;
I have to enable the following setting in the Global.asax, for the Session object to be accessible:
protected void Application_PostAuthorizeRequest()
{
// Enable session state in the web api post authorization
HttpContext.Current.SetSessionStateBehavior(SessionStateBehavior.Required);
}
Issue comes in when the WebAPI shown above has to be accessed via another ASP.Net MVC client, which is separately hosted on a different machine, at that time same consecutive calls do not maintain the state as shown above and thus it leads to an exception, since the consecutive calls rely on session data to proceed.
I have seen a similar issue when I seen the similar issue when I use the Fiddler Debugger, as it gets hosted as a web proxy, so consecutive calls through that too fails, since it does not maintain the state. In my understanding, issue is due to setting the Cookie across domain, which doesn't seem to work across domains due to security reason
I know a workaround is to use an application wide variable like Cache, but please suggest if you have a way to get the SessionState work. Let me know if you need more details.
If you have not setup an alternative way to do SessionState, then the default behavior is to do it InMemory on the server. This is why you are seeing issues when the request is handled by a different ASP.NET server.
Web API calls are meant to be stateless. That is, they should not perform like a classic ASP.NET application that relies on the framework to store user specific information in Session variables across HTTP requests. For each call, pass in a user-specific identifier or token that you can then use to lookup information stored in your backend. You can store this information in your database or a distributed cache like MemCache for faster retrieval.

Session is Null (No session at all) in class, but session does exist when accessing from aspx page

I am working on a multi developer web app. I am trying to sort out an issue that came up with one dev not being able to access session variables in his custom classes.
I synced his changes, and the same issue happens on my dev machine. (I.e., its not IIS specific)
Upon further inspection, the session object completely disappears (there is no session, nto even an empty session with a session ID. Any attempt to access HttpContext.Current.Session throws a null reference exception.
Running the page code again after setting some session variables, shows the variable are all saved and acting normal in the session that I can access from the page itself . (The session object behaves as it normally does)
So to be clear, in the same process, debugging from page through to custom class, the session object is accessible in the page, not existing in custom class, and when returning to the page, its available again.
I have tried setting just a normal string session var to eliminate possible problems with my variable (object) stored in the session. The same issue persists.
Any ideas?
Alrighty then.. always helps to bounce it off a wall :-)
We were using a textbox autocomplete extender that was referencing our own custom webmethod, (inside our app in a custom class). It seem the webmethod decoration forced it to operate stateless... hence no session.
We moved this webmethod decorated function into our page-codebehind page, and it now calls the other custom classes "with" session object availability.

Resources