cancel
Showing results for 
Search instead for 
Did you mean: 

Question on HTTP requests

TracySchultz
Level 6
For the HTTP request action is it possible to keep the session open so you can do multiple requests on the same session?

In Powershell you can do this with Invoke-WebRequest and I was curious if it's possible in BP within the confines of the existing VBO's.

------------------------------
Tracy Schultz
------------------------------
6 REPLIES 6

david.l.morris
Level 15
It is possible with C#/VB, but as you said the existing VBO's don't support that, as far as I'm aware. It shouldn't be that difficult to edit the VBO or create a new action (etc.) that uses edited code. I Googled a bit, and it looks pretty clear that you'll need to remove the Using statement that wraps the request call and instead use a CookieContainer to hold onto to the session which is used for each subsequent call. I'm not sure but I imagine you'd want to deal with closing it since the Using statement wouldn't be there anymore.

------------------------------
Dave Morris
3Ci @ Southern Company
Atlanta, GA
------------------------------

Dave Morris, 3Ci at Southern Company

Thanks Dave! My own research was turning that up. Curious if you could open it the initialize phase and close it in the clean up and have all calls made to it in the other areas.

Sent from my iPhone
________________________________
DISCLAIMER: This message is confidential and may be privileged. If you are not an intended recipient, please notify the sender immediately by email or phone and permanently delete the message from your system before reviewing, copying, or distributing. You may call us at (800) 332-7952.

------Original Message------

It is possible with C#/VB, but as you said the existing VBO's don't support that, as far as I'm aware. It shouldn't be that difficult to edit the VBO or create a new action (etc.) that uses edited code. I Googled a bit, and it looks pretty clear that you'll need to remove the Using statement that wraps the request call and instead use a CookieContainer to hold onto to the session which is used for each subsequent call. I'm not sure but I imagine you'd want to deal with closing it since the Using statement wouldn't be there anymore.

------------------------------
Dave Morris
3Ci @ Southern Company
Atlanta, GA
------------------------------

Yeah, absolutely.

I suppose there are two things to note when doing this:
  1. While the Initialize stage seems to work as the Constructor or is run when the Constructor runs, I think the scope of a code stage run within that page would mean you'll want to hold the object in or generate it from the Global Code. In fact, you don't really need any code on the Initialize page. You should be able to create your object (C# object) from the Global code itself and it will remain in scope until the object (BP object) is unloaded (i.e.-when the session ends or when the subprocess ends if it is being called from in a subprocess)
  2. You may know this already, but the way object instances work in BP is slightly awkward in my opinion. As far as I know, there's no way to reference a specific instance of an object. So, to make sure you're truly using the same instance (BP object instance), you should call it from the same level all the time. For example, if you're making HTTP calls from a process, then always call it from the process level not from inside any objects or any subprocesses. As soon as you change the 'level' from which the call is made, it is using a different instance (BP object instance) of that HTTP object. You may already know what I'm talking about so I'll leave it there unless you need further explanation.

Also, if you end up making a new version of the object, you should consider sharing in the Community somewhere because that sounds useful, especially if you're confident about the proper management of the instance (the C# object).

------------------------------
Dave Morris
3Ci @ Southern Company
Atlanta, GA
------------------------------

Dave Morris, 3Ci at Southern Company

Dave I wasn't aware of item 2. Based on that info I'm probably going to just build each one as it's own process in the VBO where it opens runs while storing the cookie and then closes itself.

Thank you so much for the insight on this.

Tracy

------------------------------
Tracy Schultz
------------------------------

Dave,

Question for you. I'd like to contribute back to the community by posting my coded solution. Is it typical to just post the code from the code block in the post?

------------------------------
Tracy Schultz
------------------------------

That's a good question. I personally often insert code samples into a post, but I think the ideal way would be to upload a file to the Library associated with the Community that makes most sense. I glanced around, and I imagine Tech Chat may be as good as any. You should be able to click the Library tab above on this page and then upload the a file there.

Then, I'd suggest putting a link here in this thread. And then when people ask questions related to this, any of us who are aware of that code can link to it or to this post in answer to those future questions people ask. For an example, this is what I currently do when people ask about extra functionality in the MS Outlook Email VBO. I link to this, depending on what functionality is being looked for: here.

------------------------------
Dave Morris
3Ci @ Southern Company
Atlanta, GA
------------------------------

Dave Morris, 3Ci at Southern Company