Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
add_cost_center_api [2014/06/24 17:15]
ybarajas
add_cost_center_api [2014/06/24 22:43] (current)
ybarajas [Examples]
Line 1: Line 1:
 +======Add a Cost Center======
  
 +
 +
 +==Resource URL==
 + 
 +<​code>​
 +/​moservices/​rest/​api/​ipass/​{COMPANY_ID}/​mo/​costcenter
 +</​code>​
 +
 +==HTTP POST==
 +Add a Cost Center.
 +
 +==POST Parameters==
 +
 +^ Parameter ^ Value ^ Description ^
 +|COMPANY_ID | Your companyId can be found in the Open Mobile Portal.|Mandatory|
 +|action|createCostCenter|Mandatory|
 +|User-Agent|apiuser|Mandatory. This helps us route your API call appropriately.|
 +
 +==Sample XML Payload==
 +
 +<​code>​
 +<​costcenter>​
 +   <​name>​Finance Department</​name>​
 +   <​costId>​Finance</​costId>​
 +   <​assignedCount />
 +   <​childCompany />
 +</​costcenter>​
 +</​code>​
 +
 +^ Parameter ^ Description ^ 
 +|name | Mandatory|
 +|costId| Mandatory|
 +|childCompany|Optional. The ID of the child companies (if Cost Center is enabled with the support of Child Companies).|
 +
 +=====Examples=====
 +
 +In this example, a Cost Center named "​Finance Department"​ will be created under the Acme company (ID 987654).
 +
 +==cURL:==
 +
 +<​code>​
 +curl -k --request POST -b tmpCookies.txt -d input.xml -H “Content-Type:​ text/xml” "​https://​openmobile.ipass.com/​moservices/​rest/​api/​ipass/​987654/​mo/​costcenter?​action=createCostCenter&​User-Agent=apiuser"​
 +</​code>​
 +
 +<​note>​The **input.xml** contains the **XML Payload**.</​note>​
 +
 +==Java:==
 +
 +<​code>​
 +String reportURI = "/​moservices/​rest/​api/​ipass/"​ + companyId + "/​mo/​costcenter?​action=createCostCenter&​User-Agent=apiuser";​
 +HttpPost reportPost = new HttpPost(BASE_URL + reportURI);
 +
 +StringBuffer result = new StringBuffer();​
 +result.append("<​costcenter>​\n"​);​
 +result.append("<​name>"​).append(costCenterName).append("</​name>​\n"​);​
 +result.append("<​costId>"​).append(costCenterId).append("</​costId>​\n"​);​
 +result.append("<​assignedCount>"​).append(""​).append("</​assignedCount>​\n"​);​
 +result.append("<​childCompany>"​).append(""​).append("</​childCompany>​\n"​);​
 +result.append("</​costcenter>​\n"​);​
 +
 +StringEntity entity = new StringEntity(result,​ "​text/​xml",​ HTTP.DEFAULT_CONTENT_CHARSET);​
 +reportPost.setEntity(entity);​
 +
 +HttpResponse postResponse = httpClient.execute(reportPost);​
 +</​code>​
 +
 +
 +
 +----
 +
 +Go to: **[[:​api_documentation|REST API Overview]] > [[:​manage_cost_center|Manage Cost Center]]**
 

©2015 iPass Inc. All rights reserved. Terms of Use