Retrieve Building Information - Coming soon... targeted release 21.2
Name | Type | Length | Description |
---|---|---|---|
bldgCode | System.String | 2 | [Required] Building code to search for (leave blank for all). |
buildingCode | System.String | 2 | Building Code |
POST http://localhost/FusionServices/v3/Naviline/ProductInventory/RetrieveBuildingInfo
Name | Description |
---|---|
BuildingCode | Building Code |
BuildingAddr1 | Building Address Line 1 |
BuildingAddr2 | Building Address Line 2 |
BuildingAddr3 | Building Address Line 3 |
BuildingCity | Building City |
BuildingState | Building State |
BuildingZip | Building Zip |
AssetAcctNo | Asset Account Number |
ExpendAcctNo | Expenditure Account Number |
RevenueAcctNo | Revenue Account Number |
SurchargePercentage | Surcharge Percent |
ActiveFlag | Active Flag |
ErrorCode | 0000 = Success. |
ErrorDescription | Success if success, otherwise returns a descriptive error message. |
using System.Net;
using Newtonsoft.Json.Linq;
public void MethodName(parms)
{
string uri = "http://localhost/FusionServices/v3/Naviline/ProductInventory/RetrieveBuildingInfo";
System.Collections.Specialized.NameValueCollection postParms =
new System.Collections.Specialized.NameValueCollection();
// Set paramater values
postParms.Add("bldgCode",System.Web.HttpUtility.UrlEncode("CO"));
WebClient req = new WebClient();
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
wc.Headers.Set("X-APPID", "YOURID");
wc.Headers.Set("X-APPKEY", "YOURKEY");
byte[] responseBytes = wc.UploadValues(new Uri(uri), "POST", postParms);
string stringResult = Encoding.UTF8.GetString(responseBytes);
JObject response = JObject.Parse(stringResult);
string error = response["OutputParms"]["ErrorCode"].ToString();
if (error == "0000")
{
JArray jRows = (JArray)response["Rows"];
foreach (JObject row in jRows)
{
string BuildingCode = row["BuildingCode"].ToString();
string BuildingAddr1 = row["BuildingAddr1"].ToString();
string BuildingAddr2 = row["BuildingAddr2"].ToString();
string BuildingAddr3 = row["BuildingAddr3"].ToString();
string BuildingCity = row["BuildingCity"].ToString();
string BuildingState = row["BuildingState"].ToString();
string BuildingZip = row["BuildingZip"].ToString();
string AssetAcctNo = row["AssetAcctNo"].ToString();
string ExpendAcctNo = row["ExpendAcctNo"].ToString();
string RevenueAcctNo = row["RevenueAcctNo"].ToString();
string SurchargePercentage = row["SurchargePercentage"].ToString();
string ActiveFlag = row["ActiveFlag"].ToString();
// TODO - YOUR CODE HERE
}
}
}
using System;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Collections.Specialized;
using FusionServiceHelper.Models;
// NOTE: Use the namespace generated when you add the class, so that it is correct.
namespace FusionRazor.Models
{
public class PostRetrieveBuildingInfo
{
// Add property for each input param in order to map a field to it
[Required(ErrorMessage = "Required")]
[RegularExpression("^(?=.{0,2}$).*", ErrorMessage = "Must be 2 characters or less. ")]
public string bldgCode{get; set;}
[RegularExpression("^(?=.{0,2}$).*", ErrorMessage = "Must be 2 characters or less. ")]
public string buildingCode{get; set;}
public PostRetrieveBuildingInfo()
{
//Set any defaults here
}
}
}
@* NOTE: Use Add->View to add the View. *@
@* NOTE: Check the 'Create strongly-typed view checkbox, and select the PostRetrieveBuildingInfo class. *@
@* NOTE: Select Edit as the Scaffold template. *@
@* NOTE: Use the @model line that is generated at the top. Replace the rest with the lines below.
@model FusionRazor.Models.PostRetrieveBuildingInfo
@{
ViewBag.Title = "PostRetrieveBuildingInfo";
}
<h2>PostRetrieveBuildingInfo</h2>
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>PostRetrieveBuildingInfo</legend>
<div class="editor-label">
@Html.LabelFor(model => model.bldgCode)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.bldgCode)
@Html.ValidationMessageFor(model => model.bldgCode)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.buildingCode)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.buildingCode)
@Html.ValidationMessageFor(model => model.buildingCode)
</div>
<p>
<input type="submit" value="Submit"/>
</p>
</fieldset>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
using System;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FusionServiceHelper.Models;
// NOTE: Replace 'MyController' with the name of your controller.
//
// GET: /MyController/PostRetrieveBuildingInfo
public ActionResult PostRetrieveBuildingInfo()
{
// Create a new instance of the model to pick up any default values.
PostRetrieveBuildingInfo model = new PostRetrieveBuildingInfo();
// pass model to set to default values
// NOTE: Change 'MyFolderPath' to the path to the .cshtml file.
return View("~/Views/MyFolderPath/PostRetrieveBuildingInfo.cshtml", model);
}
//
// POST: /MyController/PostRetrieveBuildingInfo
[HttpPost]
public ActionResult PostRetrieveBuildingInfo(FormCollection collection)
{
string url = "v3/Naviline/ProductInventory/RetrieveBuildingInfo";
// Get the value from each input field
NameValueCollection inputParms = new NameValueCollection();
inputParms.Add("bldgCode", collection["bldgCode"]);
inputParms.Add("buildingCode", collection["buildingCode"]);
try
{
// Send the request
FusionServiceRequest request = new FusionServiceRequest();
FusionServiceResult result = request.Post(url, inputParms);
return View("Result", result);
}
catch(Exception e)
{
HandleErrorInfo info = new HandleErrorInfo(e, "MyController", "PostRetrieveBuildingInfo");
return View("Error", info);
}
}