Access Endpoint by Ruby

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

Create based on a sample code on Endpoint page

require 'net/https'                 <From here, copy from Template>
require "json"

uri = URI.parse("https://dbaassandbox.matsuesoft.co.jp/????/proxyserver-AssetInfo-GetSpecificAssetByBarcode.php")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri.path)
req["Content-Type"] = "application/json"
req.body = JSON.generate({
    "TOKEN"=> "????",
    "param_AssetInfo_Barcode_where"=> "9784845623556"             ← Specify Barcode to get data
})
res = http.request(req)
if res.code != "200" then
    # Error Occured
else
    # Success
    json_response = JSON.parse(res.body)
    if json_response["_status"] == "OK" then
        # Success. Result is in: json_response["Result"]             <Until here, copy from Template>
        ↓Add from here
        if json_response["Result"] then
            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"
        end
        ↑Add until here
    else              <From here, copy from Template>
        print "Error! Result: " + json_response["_status"] + " : " + json_response["Message"] + "\n";
    end
end      <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

※In case of Windows, you may need to setup regarding to SSL to call SSL site.

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