The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Accessing CPanel UAPI from command line on Linux / Mac OS

Discussion in 'cPanel Developers' started by chicagosky, Dec 26, 2014.

  1. chicagosky

    chicagosky Registered

    Joined:
    Dec 8, 2014
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Hello

    I am trying to access the CPanel UAPI functions via command line on Mac OS and am doing so using the below syntax
    (am trying to add an email forwarder)

    Code:
    curl --user username:password -k  https://160.1.254.120:2083/execute/Email/add_forwarder?email=temp_forward&domain=mydomain.com&fwdopt=pipe&pipefwd=php/piper.php&
    The response I get for this is as below
    Code:
    {"messages":null,"errors":null,"status":1,"metadata":{"transformed":1},"data":[]}
    But when I check the cPanel, the new forwarder has not been added.

    Am I doing something wrong?

    Thanks in advance
     
  2. cPAndrewHodge

    cPAndrewHodge cPanel UI Developer
    Staff Member

    Joined:
    Dec 10, 2012
    Messages:
    52
    Likes Received:
    3
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    I tried running a similar command on my development box and got this response

    Code:
    devserver:2083/execute/Email/add_forwarder?email=reseller%40reseller.tld&fwdopt=pipe&pipefwd=echo
    Code:
    {"messages":null,"errors":null,"status":1,"metadata":{"transformed":1},"data":[{"email":"reseller@reseller.tld","domain":"reseller.tld","forward":"|/home/reseller/echo"}]}
    I also did this command to match yours

    Code:
    devserver:2083/execute/Email/add_forwarder?email=reseller&fwdopt=pipe&pipefwd=echo&domain=reseller.tld
    Code:
    {"messages":null,"errors":null,"status":1,"metadata":{"transformed":1},"data":[{"email":"reseller@reseller.tld","domain":"reseller.tld","forward":"|/home/reseller/echo"}]}
    and had success as well.

    Now when I tried an account that I didn't have access to I got this response

    Code:
    devserver:2083/execute/Email/add_forwarder?email=reseller&fwdopt=pipe&pipefwd=echo&domain=notsomethingiown.tld
    Code:
    {"messages":null,"errors":["Error opening “/etc/valiases/notsomethingiown.tld” to write: Permission denied at /usr/local/cpanel/Cpanel/Email/Aliases.pm line 114.\n"],"status":0,"metadata":{},"data":null}
    
    At this point I'm unsure why success or failure data isn't being generated for you. I would recommend opening a ticket as our support team is amazing and should be able to help you out.
     
Loading...

Share This Page