<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: sahul</title>
    <description>The latest articles on DEV Community by sahul (@smilysahul).</description>
    <link>https://dev.to/smilysahul</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1119406%2F94c95912-4831-46bc-a8f0-76856b26ad37.png</url>
      <title>DEV Community: sahul</title>
      <link>https://dev.to/smilysahul</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/smilysahul"/>
    <language>en</language>
    <item>
      <title>Send request to biometric device in the specified format</title>
      <dc:creator>sahul</dc:creator>
      <pubDate>Tue, 22 Aug 2023 08:30:02 +0000</pubDate>
      <link>https://dev.to/smilysahul/send-request-to-biometric-device-in-the-specified-format-4712</link>
      <guid>https://dev.to/smilysahul/send-request-to-biometric-device-in-the-specified-format-4712</guid>
      <description>&lt;p&gt;I have bought a biometric device to connect with my react JS.In that when I try to send request I'm getting error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useEffect } from "react";
import axios from "axios";

const FingerprintPage = () =&amp;gt; {
  const discoverAVDM = async () =&amp;gt; {
    try {
      // Make an RDSERVICE request to the RD Service
      const rdServiceResponse = await axios.request({
        method: "RDSERVICE",
        url: "http://127.0.0.1:11100/",
      });
      if (rdServiceResponse.status === 200) {
        console.log("RDSERVICE request successful.");
        // Handle the response data if needed
        console.log(rdServiceResponse.data); // Log the AVDM data
      } else {
        console.log("RDSERVICE request failed.");
        // Handle the error or retry the request if needed
      }

      // Process AVDM discovery data if applicable
      // ...
    } catch (error) {
      console.error("Error performing AVDM discovery:", error);
      // Handle the error
    }
  };

  const info = async () =&amp;gt; {
    try {
      // Make an RDSERVICE request to the RD Service
      const rdServiceResponse = await axios.request({
        method: "DEVICEINFO",
        url: "http://127.0.0.1:11100/rd/info",
      });
      if (rdServiceResponse.status === 200) {
        console.log("info request successful.");
        // Handle the response data if needed
        console.log(rdServiceResponse.data); // Log the AVDM data
      } else {
        console.log("info request failed.");
        // Handle the error or retry the request if needed
      }

      // Process AVDM discovery data if applicable
      // ...
    } catch (error) {
      console.error("Error performing info :", error);
      // Handle the error
    }
  };

  const capture = async () =&amp;gt; {
    try {
        const format = 0;
        const pidVer = '2.0';

        const rdServiceResponse = await axios.request({
            method: "CAPTURE", // Custom method
            url: `http://127.0.0.1:11100/rd/capture?format=${format}&amp;amp;pidVer=${pidVer}`,
            headers: {
                "Content-Type": "text/xml",
            },
        });

        if (rdServiceResponse.status === 200) {
            console.log("Capture request successful.");
            // Handle the response data if needed
            console.log(rdServiceResponse.data); // Log the response data
        } else {
            console.log("Capture request failed.");
            // Handle the error or retry the request if needed
        }
    } catch (error) {
        console.error("Error performing capture:", error);
        // Handle the error
    }
};


  return (
    &amp;lt;div&amp;gt;
      &amp;lt;div&amp;gt;
        {/* Add a button to initiate the AVDM discovery */}
        &amp;lt;button onClick={discoverAVDM}&amp;gt;Discover AVDM&amp;lt;/button&amp;gt;
        &amp;lt;button onClick={info}&amp;gt;info&amp;lt;/button&amp;gt;
        &amp;lt;button onClick={capture}&amp;gt;capture&amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default FingerprintPage;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this discoverAVDM and device info is working fine but the capture is not working. The documentation provided for me is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Following is the request format:
CAPTURE http://127.0.0.1:&amp;lt;rd_service_port&amp;gt;/&amp;lt;CAPTURE_path&amp;gt; 
HOST: 127.0.0.1:&amp;lt;port&amp;gt; 
&amp;lt;PidOptions ver=""&amp;gt; 
&amp;lt;Opts fCount="" fType="" iCount="" iType="" pCount="" pType="" format="" pidVer="" timeout="" 
otp="" wadh="" posh="" env=""/&amp;gt; 
&amp;lt;Demo&amp;gt;&amp;lt;/Demo&amp;gt; 
&amp;lt;CustOpts&amp;gt; 
&amp;lt;!-- no application should hard code these and should be configured on app or AUA servers. These 
parameters can be used for any custom application authentication or for other configuration 
parameters. Device providers can differentiate their service in the market by enabling advanced 
algorithms that applications can take advantage of. --&amp;gt; 
&amp;lt;Param name="" value="" /&amp;gt; 
&amp;lt;/CustOpts&amp;gt; 
&amp;lt;/PidOptions&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PidOptions:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;ver: Version of the PidOtopns spec. Currently it is “1.0”. This is necessary to allow applications to &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Opts&lt;/strong&gt; &lt;br&gt;
Int fCount (optional) number of finger records to be captured (0 to 10) &lt;br&gt;
Int fType (optional) ISO format (0 for FMR, 1 for FIR, 2 for both), 0 (FMR) is default&lt;br&gt;
Int iCount (optional) number of iris records to be captured (0 to 2) &lt;br&gt;
Int iType (optional) ISO format (0 for IIR), 0 (IIR) is default &lt;br&gt;
Int pCount (optional) number of face photo records to be captured (0 to 1). Currently face &lt;br&gt;
matching is not supported. &lt;br&gt;
Int pType (optional) face format. Currently face matching is not supported. &lt;br&gt;
Int format (mandatory) 0 for XML, 1 for Protobuf &lt;br&gt;
String pidVer (mandatory) PID version &lt;br&gt;
Int timeout capture timeout in milliseconds &lt;br&gt;
String otp (optional) OTP value captured from user in case of 2-factor auth &lt;br&gt;
String wadh (optional) If passed, RD Service should use this within PID block root element “asis”.&lt;br&gt;
String env (optional) UIDAI Authentication environment for which capture is called. Valid values &lt;br&gt;
are "P" (Production), "PP" (Pre-Production), and "S" (Staging). If blank or if the attribute is not &lt;br&gt;
passed, RD service should default this to "P". This is provided to allow same RD service to use &lt;br&gt;
different UIDAI public key based on the environment&lt;br&gt;
gracefully upgrade even when RD service may be been upgraded&lt;br&gt;
String posh (optional) if specific positions need to be captured, applications can pass a comma &lt;br&gt;
delimited position attributes. See “posh” attribute definition in Authentication Specification for &lt;br&gt;
valid values. RD Service (if showing preview) can indicate the finger using this. If passed, this &lt;br&gt;
should be passed back within PID block. Default is “UNKNOWN”, meaning “any” finger/iris can &lt;br&gt;
be captured&lt;/p&gt;

&lt;p&gt;Can you help how to send this request &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
