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.

Json api

Discussion in 'cPanel Developers' started by tasgray, Apr 14, 2014.

  1. tasgray

    tasgray Registered

    Joined:
    Apr 11, 2014
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Hi there,

    I've been developing a tool to create DNS records on cPanel hosting accounts for Office 365. I've been pretty successful getting this to work when logging in via WHM using the addzonerecord command. Problem is, many of the people who use this tool will not have WHM accounts. Therefore, I need it to work with cPanel accounts. This is where my confusion begins.

    From what I've worked out so far, the JSON api works with both WHM and cPanel. However, the 'addzonerecord' function seems to be available only in WHM.

    For example, if I try the following get request in the browser after succesfully logging in to WHM it works.

    /https://myserver.com:2087/cpsess9045407411/json-api/listzones

    However, if I try the same thing on a cPanel session, like the example below I get a 404 error.

    /https://myserver.com:2083/cpsess9045407411/json-api/listzones


    So my question really boils down to this - is it possible to manipulate DNS records via the JSON api on cPanel accounts or is this only available to WHM accounts?

    Many thanks
     
  2. tasgray

    tasgray Registered

    Joined:
    Apr 11, 2014
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Hi there,

    Thanks for the quick response.

    I was able to answer my own question a few hours after I wrote this post. However, I ran into another issue which is the zoneedit command's inability to create SRV records. Is there any way of doing this using the API that you know of?

    Tas
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  4. tasgray

    tasgray Registered

    Joined:
    Apr 11, 2014
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Hi Michael,

    Yes that link is useful but I am pretty sure it will only work with WHM accounts unless I'm mistaken?

    To be clear, I need a way to add SRV records to cPanel accounts without the use of WHM. In other words, I need to interact with an API that works with cPanel accounts, not WHM.

    Hope that makes sense.

    Tas
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Upon further testing, I verified it's not possible to add SRV records through cPanel. URL tested:

    Code:
    http://hostname:2082/cpsess12345678/frontend/x3//json-api/cpanel?cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=ZoneEdit&cpanel_jsonapi_func=add_zone_record&domain=example.com&type=SRV&name=_service._protocol.example.com&priority=0&weight=0&port=1234&target=service.example.com
    Result:

    Code:
    "You may only add A, CNAME, or TXT records"
    You may want to vote and add your feedback to this feature request:

    Allow Advanced Zone Editor To Add All Records

    That feature is for the advanced zone editor, but it's the same restriction that you see with the API.

    Thank you.
     
Loading...

Share This Page