Overview
This blog is an introduction to show developers how to retrieve a list of customers XML API.
refer to the documentation for the XML API to display a complete guide with samples to programmatically communicate with the API.
Getting started
the solution is a single-page application with HTML and jQuery support to post a request to the XML API using basic authentication.
sample code
The following code example uses jQuery to request the XML API to retrieve a list of all customers:
$ ajax ({type :. "POST", url: "https: //cortexweb/CortexAPI/Default.aspx ', contentType:" application / xml ", dataType:' text 'async: false, username" cspadmin_csp "password" password123 "data" '+''+' ';});'+'
Here is a screenshot of the application screen (Request.html):
Request XML
response XML
CSP 1 Service Provider Cortex csp.local provisioned False North 27 North north.local provisioned False
download
Click here to download the application from a single page.
Converting XML to JSON
If you prefer to work with JSON results instead of XML so I suggest trying a XML to JSON jQuery plug-in to convert the XML response JSON
For example :.
.done (function (data) {var = $ jsonData .xml2json (data);});
Errors
areas of Cross website
Make sure that the solution is deployed in the area to avoid area of the site or cross site scripting errors crossed. The following line was added to the sample code to enable cross-domain requests:
// Enable cross-domain requests (Header: Access-Control-Allow-Origin) $ .support.cors = true;
certificate errors
the solution does not work on SSL / HTTPS unless a valid certificate is configured for XML Web API service.
browser support
The solution has been tested with Internet Explorer and Chrome
If you get. "NetworkError: A network error occurred." Chrome error and then try to deploy the file to your Request.html API folder, such as "C:. inetpub Cortex management CortexAPI"
This comment has been removed by the author.
ReplyDelete