Access Endpoint by Perl

Access Endpoint of "Get Data by Barcode" which was created on example "Manage Item by Barcode by using Camera on Web Browser" by perl.

Create based on a sample code on Endpoint page

use LWP::UserAgent;                 <From here, copy from Template>
use JSON;

my $url = 'https://dbaassandbox.matsuesoft.co.jp/?????/proxyserver-AssetInfo-GetSpecificAssetByBarcode.php';
my $json = {
    "TOKEN"=> "?????????",
    "param_AssetInfo_Barcode_where"=> "9784845623556"             ← Specify Barcode to get data
};
my $req = HTTP::Request->new('POST', $url);
$req->header('Content-Type' => 'application/json');
$req->content(encode_json $json);
my $ua = LWP::UserAgent->new;
my $response = $ua->request($req);

if ($response->is_success) {
my $json_response = JSON->new()->decode($response->content);
if ($json_response->{_status} eq "OK") { # Success. Result is in: $json_response->{Result} <Until here, copy from Template> ↓Add from here if ($json_response->{Result}) {
print "Result - Item Name: " . $json_response->{Result}->{ItemName} . "\n"; ← Display Result
print "Result - Description: " . $json_response->{Result}->{Description} . "\n"; Display Result
print "Result - Barcode: " . $json_response->{Result}->{Barcode} . "\n"; Display Result
} else {
print "No Item matched\n";

}
↑Add until here } else { <From here, copy from Template>
print "Error! Result: " . $json_response->{_status} . " : " . $json_response->{Message} . "\n";
}
} <Until here, copy from Template>

After execute, result will be displayed as below:

Result - Item Name: DEF Travel Book
Result - Description: This is DEF...
Result - Barcode: 9784845623556

※Need JSON module of perl to execute sample.

Back to top

LoginLogin with this Site's User Name (ID)
Quick Login:Quick Login by Facebook ID (Keep Login Option:ON) / Newly Register


Inquiry

© 2016-2024 Matsuesoft Corporation