1. Pascal Phan
  2. PowerServer
  3. Wednesday, 11 January 2023 20:54 PM UTC

I got this error (See attachment)

Application terminated.

Error: Session not created. Please create a session using

BeginSession. (Web API:

http://localhost:5099/api/ServerApi/ConnectAndCreateTransaction)

Note: I had tried this link: Trying powerserver from powerbuilder 2022 (appeon.com)

But it did not work. 

 

Attachments (1)
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 11 January 2023 21:02 PM UTC
  2. PowerServer
  3. # 1

Hi Pascal,

Do you have the "Begin session by code" option in the Application object checked?

 

Regards,
Francisco

Comment
  1. Francisco Martinez @Appeon
  2. Wednesday, 11 January 2023 21:12 PM UTC
If you do have that option enabled, that means you need to manually call BeginSession().

This option is generally used to configure external authentication (for example through OAuth), so that no operations can be performed unless the user has properly authenticated. If you're not making use of this external authentication, then there is no need to have the "Begin session by code" option active and you can disable it. After disabling it, this error should go away



Regards - Francisco

  1. Helpful
  1. Francisco Martinez @Appeon
  2. Wednesday, 11 January 2023 21:12 PM UTC
  1. Helpful
  1. damian jimenez
  2. Wednesday, 1 February 2023 19:21 PM UTC
today i had the same error. with beginsession()

In my case is the same app C/S and Powerserver, may be is your case Pascal



it was working OK without authentication, but when i`m add this configuration get the same error

( im my case add Oauth Server)

i did step by step the documentation (https://docs.appeon.com/ps2022/OAuth_client_app.html ) [1]

--------------------------------------------------------------------------------------------------------------------------------

THANKS TO Chris Pollach @Appeon AND Francisco Martinez @Appeon previous comments here i add this :

--------------------------------------------------------------------------------------------------------------------------------

In my case is the same app C/S and Cloud, then i change step 4. (1) add an IF Clause in open() event in application object



IF IsPowerserverApp() THEN

[....HERE THE CODE https://docs.appeon.com/ps2022/OAuth_client_app.html Scripts step 4 ...]

//Authorization

...................

ELSE

IF getsessionid ( ) = "" THEN ll_return = beginsession ( )

.....

END IF



with this, when is C/S execute beginsession() manually wich is necesary when "Begin session by code" is checked in additional properties (like Francisco said before )



with this change, works ok in Client/Server and Cloud Powerserver

I hope it works for you Pascal, regards

  1. Helpful
There are no comments made yet.
Pascal Phan Accepted Answer Pending Moderation
  1. Wednesday, 11 January 2023 21:12 PM UTC
  2. PowerServer
  3. # 2
 The error occurred at: CONNECT USING SQLCA;
Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 11 January 2023 21:22 PM UTC
  2. PowerServer
  3. # 3

Hi Pascal;

  Here is the code that I use in the STD framework when the Application Object "Begin session by code" property is set to TRUE. Here is the code I use on my Transaction Object ancestor when a DB Connect is happening, as follows:

IF  go_ac.of_get_client_type( ) = "PS"  THEN                                                // PowerServer App?
    Application    lo_app                                                                                     // YES=>App pointer
    String            ls_session_id
    lo_app            =    GetApplication ( )                                                              // Load Ptr
    ls_session_id    =    lo_app.getsessionid ( )                                                     // Get PS Session
    IF  ls_session_id = ""  THEN                                                                            // Active Session?
        ii_rc        =    lo_app.beginsession ( )                                                              // NO=>Start PS Session!
        ls_msg    =    "PowerServer Session Started - RC: "                                             // Set MSG
        ii_rc         =     go_ac.of_write_log ( ls_msg + String (ii_rc ) )                               // Log PS Session start!
        ls_msg    =    "PowerServer Session No: "                                                          // Set MSG
        ls_session_id =  lo_app.getsessionid ( )                                                              // Get new PS Session #
        ii_rc         =     go_ac.of_write_log ( ls_msg + ls_session_id )                                // Log PS Session info!
        go_ac.of_set_ps_session ( ls_session_id )                                                           // Save current Session ID
    END IF
END IF

HTH

Regards .. Chris

Comment
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Thursday, 12 January 2023 06:08 AM UTC
  2. PowerServer
  3. # 4

Your Web API URL is configured as localhost.  Is the server and the client app being run on the same machine?  If server is remote machine then must use static IP address or domain name instead of localhost.  

Comment
There are no comments made yet.
Pascal Phan Accepted Answer Pending Moderation
  1. Thursday, 11 May 2023 18:03 PM UTC
  2. PowerServer
  3. # 5

Below is my code to resolve the issue:

// Check for Power Server App

If IsPowerServerApp() Then

   Long v_return

   Try
       v_return = Getapplication().Beginsession()
       if v_return <> 0 then
          Messagebox("Begin Session failed:" + string(v_return), GetHttpResponseStatusText())
      end if
   Catch (Throwable ex)
      MessageBox("Throwable", ex.GetMessage())
   End Try

End If

Note that I do not use Authentication because I am using the local IIS.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.