Web Services - Ws - GetPDocDetailNc

9/5/2019


Sample C# code to use the web service:       
private const string myUserName = "myemail@mydomain.com";
private const string myPassword = "password";
string myUrlPrefix = "https://documentvacuum.com/";

public ActionResult GetPDocDetailNc()
{
    string version = "0";
   int pDocId = 911; //make sure this is a valid PDocId
    string entityId="abcd"; //make sure this is a valid entityId
    HttpClient client = new HttpClient();
    //use either PDocId or EntityId to find the record
    string myUrlSuffix = "api/PDocDetailNcApi/GetPDocDetailNc?version=" + version +
        "&id=" + pDocId + "&identityColumn=PDocId";
    //string myUrlSuffix = "api/PDocDetailNcApi/GetPDocDetailNc?version=" + version +
    //      "&id=" + entityId +"&identityColumn=EntityId";
    string myUrl = myUrlPrefix + myUrlSuffix;

    var buffer = System.Text.Encoding.ASCII.GetBytes(myUserName + ":" + myPassword);
    var authHeader = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic",
        Convert.ToBase64String(buffer));
    client.DefaultRequestHeaders.Authorization = authHeader;
    client.DefaultRequestHeaders.Accept.Add(new
        System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

    try
    {
        var task = client.GetAsync(myUrl);
        HttpStatusCode statusCode = task.Result.StatusCode;
        var output = task.Result.Content.ReadAsStringAsync().Result;

        if (statusCode == HttpStatusCode.OK)
        {
           string outcome = "Success";
            //While the list will normally have one element, it is possible that there are two, the
            //first originally created with a pdf document, and then when the text contents are not
            //extractable this goes to status 27 and a second is created to extract text using the image
            //rather than embedded text
            List<PDocDetailNc> pddNcList = JsonConvert.DeserializeObject<List<PDocDetailNc>>(output);

            //if a document has completed processing successfully, it will be shown below
            PDocDetailNc pddNcSuccess = pddNcList.Where(x => x.PDocStatusId == 21).FirstOrDefault();
        }

        else if (statusCode == HttpStatusCode.Unauthorized)
        {
             string outcome = "Bad login credentials or insufficient account permissions";
        }

       else if (statusCode == HttpStatusCode.NotAcceptable)
       {
           string outcome = "You need to search on either PDocId or EntityId";
        }

       else if (statusCode == HttpStatusCode.NotFound)
        {
             string outcome = "We could not find any pDocDetails that match";
        }

       else if (statusCode == HttpStatusCode.InternalServerError)
        {
             string outcome = "Something else went wrong";
        }
    }
    catch (Exception e)
    {
        string s = e.Message;
    }

    return RedirectToAction("Index");
}


Other articles:
Billing - DocVacBasic & DocVacGold
Web Services - Ws - GetPDocPageClassificationNc
Web Services - Usage Charges
Postman
Web Services - Class - PDocDetailNc
Web Services - Class - PDocPageNc
Web Services - Class - PDocRowClassificationNc
Web Services - Class - PDocRowXmlNc
Web Services - Class - PdrxDataTypeNc
Web Services - Class - PdrxstnMappingNc
more