Skip to main content

xmlapi add SRV record

Comments

12 comments

  • cPanelMichael
    Hello, The following values are possible when using cPanel API 2 to add a zone record per our documentation: A CNAME TXT You will need to use WHM API 1 to add the SRV record with our API:
    0
  • vb543
    Thanks! In hopes of confirming I'm at least doing the basics correctly, I have the following line to dumpzone. Unfortunately, it's not working either. Any idea where I'm going wrong?
    print $xmlapi->api1_query("cPanelUsernName", "Email", "dumpzone", array($domain));
    Output
    {"apiversion":"1","type":"event","module":"Email","func":"dumpzone","source":"module","data":{"result":""},"event":{"result":1}}
    0
  • cPanelMichael
    Hello, Would you mind sharing the full script (minus any actual password hashes) you are using when utilizing the dumpzone WHM API 1 function? I tested with a URL such as:
    https://10.1.1.1:2087/cpsess9622297555/json-api/dumpzone?api.version=1&domain=cptest01.com
    This correctly dumped the zone in the output. Thank you.
    0
  • vb543
    Here's the dumpzone script.
    password_auth("root","rootPass"); $xmlapi->set_output('json'); $xmlapi->set_debug(1); print $xmlapi->api1_query("cPanelUserAccount", "Email", "dumpzone", array($domain)); ?>
    0
  • cPanelMichael
    You could try something like this:
    password_auth("root","password"); $xmlapi->set_debug(1); $xmlapi->set_output('json'); print $xmlapi->dumpzone( $domain );
    Thank you.
    0
  • vb543
    Thanks, that worked for the dumpzone. Could you provide an example for addzonerecord for an SRV record? Much appreciated.
    0
  • cPanelMichael
    You can find examples to use as templates when developing your own custom code at: Thank you.
    0
  • vb543
    Thanks for the examples. Based on the api1 example, I wrote the following code. Unfortunately, it does not seem to be working. Any idea where I'm going wrong?
    password_auth("root","rootpw"); $xmlapi->set_output('json'); $xmlapi->set_debug(1); print $xmlapi->api1_query("account", "Email", "addzonerecord", array( 'domain' => 'example.com', 'name' => '_minecraft._tcp.test20.example.com', 'type' => 'SRV', 'port' => '25656', 'priority' => '0', 'weight' => '0', 'target' => 'mc1.example.com', 'ttl' => '360', 'class' => 'IN',) ); ?>
    Output:
    {"apiversion":"1","type":"event","module":"Email","func":"addzonerecord","source":"module","data":{"result":""},"event":{"result":1}}
    0
  • cPanelMichael
    print $xmlapi->api1_query("account", "Email", "addzonerecord", array(

    Hello, I see a few issues with your custom script, but the most notable is you are referencing the "Email" module. You will likely want to consult with a qualified system administrator or developer if you are not comfortable with developing the script on your own. We are happy to offer guidance, but we won't be able to develop each custom script for you. The following option in Web Host Manager is a good way to test the module: "WHM Home " Development " API Shell" Note you must first enable "cPanel & WHM API shell (for developers)" under the "System" tab in "WHM >> Tweak Settings". Thank you.
    0
  • vb543
    I appreciate your help and I understand that you're not here to write my script for me, I was just trying to understand the examples for a basic api call. After realizing that there's a great deal of documentation hidden beneath the zmlapi.php file, I was able to get the addzonerecord working. Now my issue is with regards to the name field. It's duplicating the domain name and I'm not sure how to work around this. The API shell did the same thing, so it's probably an issue with my data.
    'domain' => 'domain.com', 'name' => '_service._tcp.test20.domain.com',
    Yields the following for the record's Name:
    _service._tcp.test20.domain.com.domain.com.
    I've tried removing the 'domain.com' part from the name field but that resulted in an error. Any ideas? Thanks!
    0
  • cPanelMichael
    The API shell did the same thing, so it's probably an issue with my data.

    Hello, The name entry should be:
    _service._tcp.test20
    Thank you.
    0
  • vb543
    Thought I tried that... At least it's working now! Thanks again for all of your help! I really appreciate it! :)
    0

Please sign in to leave a comment.