Can we customize mobile application server requests?

Is it possible to customize sending and processing of the requests which native mobile app performs to the server, for example add headers?

Whenever a mobile app cals server action - this generates a REST call. This means that we can't rely on session persisted between those calls, am I right?

Then we need to ensure authorization. We were using REST services before, and there we were passing authorization token (and other info we need) in headers of every request and did login inside of OnAuthentication event. But I don't see any possiblity of this in mobile app. Is there something?

You are right, there is no concept of a Session like you have with web apps. Even for Server Actions, there are no Session Variables.

Also, you do not need to add explicit authorization between the mobile app and the server when calling Server Actions, that's handled by the Platform as a black box. You would only need authorization when you would be calling a REST service from your mobile app (which is also routed via the server, so that the REST service sees the server IP address).

You are right, there is no concept of a Session like you have with web apps. Even for Server Actions, there are no Session Variables.

Also, you do not need to add explicit authorization between the mobile app and the server when calling Server Actions, that's handled by the Platform as a black box. You would only need authorization when you would be calling a REST service from your mobile app (which is also routed via the server, so that the REST service sees the server IP address).

I see, so is there no way to add headers to all requests? The thing is that we have additional login-related information, just 2 integers. When using web, they are stored in session, and when using services - sent in headers. It looks like we can't use neither of these options with mobile?

As far as your application is aware, a call to a server action is completely transparent, and works the same as a call to a client action. You can't piggyback you're own data on it. The fact that it's REST "under the hood" is abstracted away.

So I can see a number of solutions to your problem:

1) Explicitly pass the information with every Server Action you call;

2) Don't call Server Actions but use explicit REST calls, and use OnBeforeRequest/OnAfterResponse to add and parse your extra stuff;

3) Create a Session Entity to hold temporary "session" related information, and keep track of login sessions yourself. Note that even though Session variables are not used, the system still keeps track of logins and such.

Neither is ideal, so if you can get away with not doing any of this, take the opportunity :).