{"id":60,"date":"2009-11-16T10:26:32","date_gmt":"2009-11-16T15:26:32","guid":{"rendered":"http:\/\/blogs.wp.stage.cpanel.net\/2009\/11\/troubleshooting_the_xml-api\/"},"modified":"2009-11-16T10:26:32","modified_gmt":"2009-11-16T15:26:32","slug":"troubleshooting_the_xml-api","status":"publish","type":"post","link":"https:\/\/devel.www.cpanel.net\/blog\/products\/troubleshooting_the_xml-api\/","title":{"rendered":"Troubleshooting the XML-API"},"content":{"rendered":"

We have had a flurry of integration tickets over the past week, which is awesome to see.\u00a0 Most of these tickets have come down to a couple of basic problems.\u00a0 The first of which is due to some confusion about how to utilize HTTP to call\u00a0 an API function.The second problem appears to stem from a lack of information API troubleshooting tools that come with cPanel\/WHM.<\/p>\n

The first of our common problems stem from some basic confusion about how to utilize HTTP to call our API functions.\u00a0 The second of problem seems to come from a lack of information about how to use the tools that are available within cPanel and WHM for troubleshooting these API calls.<\/p>\n

So, there are numerous things that need to be understood about using HTTP when working with our XML-API.\u00a0 The first point that needs to be made is that the GET HTTP call is limited to 2048 characters.\u00a0 The RFC itself does not specify any maximum size for a GET request; however, as this limitation has been imposed by browser manufacturers, HTTP servers and clients have implemented it as well.\u00a0 This limit affects XML-API by limiting the number of characters that in can be passed via GET.\u00a0 If the number of characters exceeds 2048 (think of SSL certificates), the string will be truncated and the call will fail.\u00a0 This is why it is very important to always use POST with the XML API.<\/p>\n

The second issue that I\u2019ve been noticing is that people don\u2019t encode the data that they are passing to the XML-API.\u00a0 In most cases, this is fine; however, I\u2019ve had quite a few tickets where the developer\u00a0 is having issues with this.\u00a0 When passing something like an email account over HTTP via GET, it will have user@domain.com inside of the HTTP request.\u00a0 This is an issue because the @ symbol is reserved for specific uses, namely redirects or authentication.\u00a0 If you are using an HTTP client that does not automatically encode GET requests, the URL will be truncated.\u00a0 If you are using PHP for your interactions, the built-in url_encode function works really well for this.\u00a0 When developing in perl the URI::Escape module works quite well.<\/p>\n

When you run across issues with the XML-API, there are a few ways of troubleshooting them.\u00a0 The first is the most obvious:\u00a0 look at the error_log (located at \/usr\/local\/cpanel\/logs\/error_log).\u00a0 If there is an error with the call itself, it should show up in this log.\u00a0 Of course, this won\u2019t help much with errors inside of your application.\u00a0 For troubleshooting those, the easiest log to look at is the access_log at \/usr\/local\/cpanel\/logs\/access_log.\u00a0 This will show every URL called within cPanel using a format similar to Apache\u2019s \u2018combined\u2019 log style.<\/p>\n

A completely undocumented log that is really useful is the \u201clog-http-requests\u201d cpanel.config option.\u00a0 To enable this option:<\/p>\n

Open \/var\/cpanel\/cpanel.config in your preferred text editor.
\nAdd the following line to the file:
\nlog-http-requests=1
\nRestart cPanel:
\n\/etc\/init.d\/cpanel restart<\/em>
\nAfter doing this, if you run tail-f \/usr\/local\/cpanel\/logs\/incoming_http_requests.log<\/em> you will see something like
\n ]15421][10\/29\/2009:17:14:21 -0000][getreq 0]: [POST \/xml-api\/addip HTTP\/1.1
\n[15421][10\/29\/2009:17:14:21 -0000][headerparser 0]:Host: 127.0.0.1:2087
\n[15421][10\/29\/2009:17:14:21 -0000][headerparser 0]:Accept: *\/*
\n[15421][10\/29\/2009:17:14:21 -0000][headerparser 0]:Authorization: Basic *censored*
\n[15421][10\/29\/2009:17:14:21 -0000][headerparser 0]:Content-Type: application\/x-www-form-urlencoded
\n[15421][10\/29\/2009:17:14:21 -0000][headerparser 0]:Content-Length: 34
\n[15421][10\/29\/2009:17:14:21 -0000][killconnection]
\n[15421][10\/29\/2009:17:14:21 -0000][killconnection exit]<\/code>
\nThis allows you to ensure that the proper data is being sent to the server.<\/p>\n

Another cool feature that we\u2019ve added in newer builds of cPanel 11.25 (build # 41121 and higher) is the ability to log POSTDATA sent to the server.\u00a0 To enable this simply add log-http-requests-postdata=1 to \/var\/cpanel\/cpanel.config and restart the service.\u00a0 This will add another line of output to the incoming_http_requests.log file displaying the POSTDATA passed to the server.<\/p>\n

If you really run into a lot of trouble with the XML-API, I suggest using the XML-API PHP class or working with the API.\u00a0 This class does encoding, POST requests, and even provides some useful debugging information.<\/p>\n","protected":false},"excerpt":{"rendered":"

We have had a flurry of integration tickets over the past week, which is awesome to see.\u00a0 Most of these tickets have come down to a couple of basic problems.\u00a0 The first of which is due to some confusion about how to utilize HTTP to call\u00a0 an API function.The second problem appears to stem from […]<\/p>\n","protected":false},"author":77,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[49],"tags":[],"class_list":["post-60","post","type-post","status-publish","format-standard","hentry","category-products"],"acf":[],"yoast_head":"\nTroubleshooting the XML-API | cPanel<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/devel.www.cpanel.net\/blog\/products\/troubleshooting_the_xml-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Troubleshooting the XML-API | cPanel\" \/>\n<meta property=\"og:description\" content=\"We have had a flurry of integration tickets over the past week, which is awesome to see.\u00a0 Most of these tickets have come down to a couple of basic problems.\u00a0 The first of which is due to some confusion about how to utilize HTTP to call\u00a0 an API function.The second problem appears to stem from […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/devel.www.cpanel.net\/blog\/products\/troubleshooting_the_xml-api\/\" \/>\n<meta property=\"og:site_name\" content=\"cPanel\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cpanel\/\" \/>\n<meta property=\"article:published_time\" content=\"2009-11-16T15:26:32+00:00\" \/>\n<meta name=\"author\" content=\"cPanel Community\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cPanel\" \/>\n<meta name=\"twitter:site\" content=\"@cPanel\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"cPanel Community\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/devel.www.cpanel.net\/blog\/products\/troubleshooting_the_xml-api\/\",\"url\":\"https:\/\/devel.www.cpanel.net\/blog\/products\/troubleshooting_the_xml-api\/\",\"name\":\"Troubleshooting the XML-API | cPanel\",\"isPartOf\":{\"@id\":\"https:\/\/devel.www.cpanel.net\/#website\"},\"datePublished\":\"2009-11-16T15:26:32+00:00\",\"dateModified\":\"2009-11-16T15:26:32+00:00\",\"author\":{\"@id\":\"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/8cf97408aad4fb70cf55d11a1d4f57f8\"},\"breadcrumb\":{\"@id\":\"https:\/\/devel.www.cpanel.net\/blog\/products\/troubleshooting_the_xml-api\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/devel.www.cpanel.net\/blog\/products\/troubleshooting_the_xml-api\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/devel.www.cpanel.net\/blog\/products\/troubleshooting_the_xml-api\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/devel.www.cpanel.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Troubleshooting the XML-API\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/devel.www.cpanel.net\/#website\",\"url\":\"https:\/\/devel.www.cpanel.net\/\",\"name\":\"cPanel\",\"description\":\"Hosting Platform of Choices\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/devel.www.cpanel.net\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/8cf97408aad4fb70cf55d11a1d4f57f8\",\"name\":\"cPanel Community\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e1949945083b5526bb95711bd3d616b3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e1949945083b5526bb95711bd3d616b3?s=96&d=mm&r=g\",\"caption\":\"cPanel Community\"},\"description\":\"The web hosting industry's most reliable management solution since 1997. With our first-class support and rich feature set, it's easy to see why our customers and partners make cPanel & WHM their hosting platform of choice. For more information, visit cPanel.net.\",\"sameAs\":[\"https:\/\/cpanel.net\"],\"url\":\"https:\/\/devel.www.cpanel.net\/blog\/author\/cpadmin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Troubleshooting the XML-API | cPanel","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/devel.www.cpanel.net\/blog\/products\/troubleshooting_the_xml-api\/","og_locale":"en_US","og_type":"article","og_title":"Troubleshooting the XML-API | cPanel","og_description":"We have had a flurry of integration tickets over the past week, which is awesome to see.\u00a0 Most of these tickets have come down to a couple of basic problems.\u00a0 The first of which is due to some confusion about how to utilize HTTP to call\u00a0 an API function.The second problem appears to stem from […]","og_url":"https:\/\/devel.www.cpanel.net\/blog\/products\/troubleshooting_the_xml-api\/","og_site_name":"cPanel","article_publisher":"https:\/\/www.facebook.com\/cpanel\/","article_published_time":"2009-11-16T15:26:32+00:00","author":"cPanel Community","twitter_card":"summary_large_image","twitter_creator":"@cPanel","twitter_site":"@cPanel","twitter_misc":{"Written by":"cPanel Community","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/devel.www.cpanel.net\/blog\/products\/troubleshooting_the_xml-api\/","url":"https:\/\/devel.www.cpanel.net\/blog\/products\/troubleshooting_the_xml-api\/","name":"Troubleshooting the XML-API | cPanel","isPartOf":{"@id":"https:\/\/devel.www.cpanel.net\/#website"},"datePublished":"2009-11-16T15:26:32+00:00","dateModified":"2009-11-16T15:26:32+00:00","author":{"@id":"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/8cf97408aad4fb70cf55d11a1d4f57f8"},"breadcrumb":{"@id":"https:\/\/devel.www.cpanel.net\/blog\/products\/troubleshooting_the_xml-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/devel.www.cpanel.net\/blog\/products\/troubleshooting_the_xml-api\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/devel.www.cpanel.net\/blog\/products\/troubleshooting_the_xml-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/devel.www.cpanel.net\/"},{"@type":"ListItem","position":2,"name":"Troubleshooting the XML-API"}]},{"@type":"WebSite","@id":"https:\/\/devel.www.cpanel.net\/#website","url":"https:\/\/devel.www.cpanel.net\/","name":"cPanel","description":"Hosting Platform of Choices","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/devel.www.cpanel.net\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/8cf97408aad4fb70cf55d11a1d4f57f8","name":"cPanel Community","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e1949945083b5526bb95711bd3d616b3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e1949945083b5526bb95711bd3d616b3?s=96&d=mm&r=g","caption":"cPanel Community"},"description":"The web hosting industry's most reliable management solution since 1997. With our first-class support and rich feature set, it's easy to see why our customers and partners make cPanel & WHM their hosting platform of choice. For more information, visit cPanel.net.","sameAs":["https:\/\/cpanel.net"],"url":"https:\/\/devel.www.cpanel.net\/blog\/author\/cpadmin\/"}]}},"_links":{"self":[{"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/posts\/60"}],"collection":[{"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/users\/77"}],"replies":[{"embeddable":true,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/comments?post=60"}],"version-history":[{"count":0,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"wp:attachment":[{"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}