<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ACS REST API - Consume API using PHP CURL in DevNet General Discussions</title>
    <link>https://community.cisco.com/t5/devnet-general-discussions/acs-rest-api-consume-api-using-php-curl/m-p/3584737#M859</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Amit,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; For XML format found one similar url -&lt;A href="https://community.cisco.com/thread/48466"&gt;ACS REST API - Add Devices&lt;/A&gt; hope it helps. Just have a look .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Geevarghese&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Jul 2016 11:02:06 GMT</pubDate>
    <dc:creator>Geevarghese Cheria</dc:creator>
    <dc:date>2016-07-01T11:02:06Z</dc:date>
    <item>
      <title>ACS REST API - Consume API using PHP CURL</title>
      <link>https://community.cisco.com/t5/devnet-general-discussions/acs-rest-api-consume-api-using-php-curl/m-p/3584736#M858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Has anyone tried PHP Curl to consume ASC API?&lt;/P&gt;&lt;P&gt;I have tried following code but getting following error, can anyone hep to fix this?&lt;/P&gt;&lt;PRE class="jive-pre"&gt;&amp;lt;errorCode&amp;gt;61000&amp;lt;/errorCode&amp;gt;&amp;lt;httpCode&amp;gt;400&amp;lt;/httpCode&amp;gt;&amp;lt;moreErrInfo&amp;gt;XML Parsing Error:&amp;nbsp; Premature end of file.. Premature end of file.. &amp;lt;/moreErrInfo&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following code is to fetch one record, I'm not sure that this API accept XML data as POST/PUT value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;---------------&amp;nbsp; PHP CUrl Code Start------------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$headers = array('Content-type: application/xml');&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;$url = '&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://SERVER/Rest/NetworkDevice/Device/op/query';" rel="nofollow" target="_blank"&gt;https://SERVER/Rest/NetworkDevice/Device/op/query';&lt;/A&gt;&lt;/P&gt;&lt;P&gt;$username = 'some-user';&lt;/P&gt;&lt;P&gt;$password = 'password';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$data = "&amp;lt;?xml version='1.0' encoding='UTF-8' standalone='yes'?&amp;gt;&amp;lt;ns2:query xmlns:ns2='query.rest.mgmt.acs.nm.cisco.com'&amp;gt;&amp;lt;numberofItemsInPage&amp;gt;1&amp;lt;/numberofItemsInPage&amp;gt;&amp;lt;startPageNumber&amp;gt;1&amp;lt;/startPageNumber&amp;gt;&amp;lt;/ns2:query&amp;gt;";&lt;/P&gt;&lt;P&gt;$data = urlencode(utf8_decode(trim($data)));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$ch = curl_init();&lt;/P&gt;&lt;P&gt;curl_setopt($ch, CURLOPT_URL, $url);&lt;/P&gt;&lt;P&gt;curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password);&lt;/P&gt;&lt;P&gt;curl_setopt($ch, CURLOPT_VERBOSE, 1);&lt;/P&gt;&lt;P&gt;curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);&lt;/P&gt;&lt;P&gt;curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);&lt;/P&gt;&lt;P&gt;curl_setopt($ch, CURLOPT_PUT, 1);&lt;/P&gt;&lt;P&gt;curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);&lt;/P&gt;&lt;P&gt;curl_setopt($ch, CURLOPT_HEADER, true);&lt;/P&gt;&lt;P&gt;curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);&lt;/P&gt;&lt;P&gt;curl_setopt($ch, CURLOPT_POSTFIELDS, $data);&lt;/P&gt;&lt;P&gt;$response-&amp;gt;data = curl_exec($ch);&lt;/P&gt;&lt;P&gt;$response-&amp;gt;httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);&lt;/P&gt;&lt;P&gt;curl_close($ch);&lt;/P&gt;&lt;P&gt;var_dump($response);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Mar 2019 10:54:56 GMT</pubDate>
      <guid>https://community.cisco.com/t5/devnet-general-discussions/acs-rest-api-consume-api-using-php-curl/m-p/3584736#M858</guid>
      <dc:creator>amitking123</dc:creator>
      <dc:date>2019-03-01T10:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: ACS REST API - Consume API using PHP CURL</title>
      <link>https://community.cisco.com/t5/devnet-general-discussions/acs-rest-api-consume-api-using-php-curl/m-p/3584737#M859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Amit,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; For XML format found one similar url -&lt;A href="https://community.cisco.com/thread/48466"&gt;ACS REST API - Add Devices&lt;/A&gt; hope it helps. Just have a look .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Geevarghese&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2016 11:02:06 GMT</pubDate>
      <guid>https://community.cisco.com/t5/devnet-general-discussions/acs-rest-api-consume-api-using-php-curl/m-p/3584737#M859</guid>
      <dc:creator>Geevarghese Cheria</dc:creator>
      <dc:date>2016-07-01T11:02:06Z</dc:date>
    </item>
  </channel>
</rss>

