Unable to use UAPI Session:create_webmail_session_for_self

shrinidhinhegde

Registered
Jun 4, 2020
1
0
0
India
cPanel Access Level
Reseller Owner
I am trying to use the UAPI API for a small project of mine. Specifically, I am using the Session:create_webmail_session_for_self
this function has both GET and POST requests. Initially I send the GET request and then parse the data and then send a POST request. I get back the URL which looks like

"https://example.com:2096/cpsess6972.../index.html?login=1&post_login=89484517050776 "

but when I paste this link on my web-browser, it again asks for the password. what is it that i am doing wrong?
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
44
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
Hello shrinidhinhegde,

The API being used is for linked nodes (currently, for linking from a parent node to a child mail node). See more about Linked Server Nodes at Link Server Nodes | cPanel & WHM Documentation

If you are working with two linked server nodes, then the remote_address parameter would be required if you are using the backend to generate a URL to use from a browser. Please see the documentation for this information:


If you are not working with two cPanel & WHM servers that are linked, then the API to use would be the following one:


*Note:* After posting this, I was informed that the create_webmail_session_for_self UAPI can be used without having a linked server node. The question still remains if you are using the remote_address parameter when running your requests. If we could have the examples of exactly what you are running to get the output, that would be helpful. Thanks!
 
Last edited:

cPanelFelipe

Member
Staff member
Apr 10, 2013
21
15
128
You need to send this API call to cPanel (port 2083), not to Webmail.

It sounds like the easiest way to do what you want to do is just to use HTTP Basic Authentication to make your API call. That way you don’t have worry about logins or anything else.

There are PHP and Perl examples here: https://documentation.cpanel.net/di...cation+-+Username+and+Password+Authentication

So your POST will look like:

https://example.com:2083/execute/Session/create_webmail_session_for_self

… with the payload being the form-encoded parameters for that API as described in the Developer Documentation.

Once you have that API response, then follow the /login directions—POSTing to Webmail this time—as given in the DD.
 
Last edited: