{"id":20255,"date":"2020-07-27T14:59:55","date_gmt":"2020-07-27T14:59:55","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/sagex3\/?p=20255"},"modified":"2024-11-26T10:51:53","modified_gmt":"2024-11-26T10:51:53","slug":"how-to-call-an-api-through-postman-tool-and-map-with-x3-fields","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/sagex3\/2020\/07\/27\/how-to-call-an-api-through-postman-tool-and-map-with-x3-fields\/","title":{"rendered":"How to Call an API Through POSTMAN Tool and Map With X3 Fields"},"content":{"rendered":"\n<p>We come across the scenario, where we will use POSTMAN software tool to examine the working of external API. Postman is a simple GUI for sending HTTP requests and viewing responses. REST services are available in <a href=\"https:\/\/www.greytrix.com\/sage-x3-erp\/\">Sage x3<\/a> which returns data in a JSON format. In this blog, we are going to visualize the mapping of fields from Postman to x3 Rest web services. <\/p>\n\n\n\n<p><strong>Example<\/strong>: In Postman IDE,<\/p>\n\n\n\n<p><strong>1. <\/strong>HTTP Request \u2014&nbsp;Request is the simplest way possible to make HTTP calls.<\/p>\n\n\n\n<p>HTTP Request contains the&nbsp;Request Method, Request URL, Authorization, Request Header, and Request Body.<\/p>\n\n\n\n<p><strong>a. Request Method: The request<\/strong> method defines the type of request to be made. There are mainly four request methods, used for creating\/updating, retrieving, and deleting data. <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>POST Request \u2014<\/strong> For Creating Or Updating data<\/li>\n\n\n\n<li><strong>PUT Request \u2014<\/strong> For Updating data<\/li>\n\n\n\n<li><strong>GET Request<\/strong> <strong>\u2014<\/strong> For Retrieving\/Fetching data <\/li>\n\n\n\n<li><strong>DELETE Request<\/strong> <strong>\u2014<\/strong> For Deleting data.<\/li>\n<\/ul>\n\n\n\n<p>Choose\nPost Method, A&nbsp;POST&nbsp;request is a method that is used when we need to\nsend some additional information inside the body of the request to the server.<\/p>\n\n\n\n<p><strong>b. Request URL: <\/strong>URL to make the HTTP request. Enter the complete URL in the URL field.<\/p>\n\n\n\n<p><strong>c. Authorization: <\/strong>An authorization token, included with requests, is used to identify the requester. Select the Basic Auth on the Type field and enter a valid Username and Password.<\/p>\n\n\n\n\n\n<p><strong>d. Request Header:<\/strong> In request headers, it contains the key-value of the application.<\/p>\n\n\n\n<p>Content-Type &#8211;&nbsp;A content type describes the format of object data. Content-type, i.e., application\/JSON which is used for the requests and responses <\/p>\n\n\n\n<p><strong>e. Request Body:<\/strong> The body Field contains the data, depending on the type of request method, to be sent with the request, the raw form of data is used for sending the request.&nbsp;<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>&#8220;name&#8221;:&#8221;Kalam&#8221;,<\/p>\n\n\n\n<p>&#8220;job&#8221;&nbsp;&nbsp; :&#8221;scientist&#8221;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p><strong>2. <\/strong>HTTP Response \u2014&nbsp;On click of the Send Button, the Response will display in JSON Format.<\/p>\n\n\n\n\n\n<p><strong>In X3:Create\nREST Web services<\/strong><\/p>\n\n\n\n<p><strong>Navigational Path:\nAll-&gt;Administration-&gt;Administration-&gt;Rest Web services<\/strong><\/p>\n\n\n\n<p><strong>Name Field: <\/strong>Enter any user defined field<\/p>\n\n\n\n<p><strong>Base URL:<\/strong> Enter the domain name of the URL<\/p>\n\n\n\n<p><strong>Example:<\/strong> Enter only domain name: http:\/\/reqres.in&nbsp; from full path: &nbsp;&nbsp;http:\/\/reqres.in\/api\/users&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/p>\n\n\n\n<p><strong>Content-Type: <\/strong>Choose Json <\/p>\n\n\n\n<p><strong>Authentication: <\/strong>Choose Basic Authentication and Enter credentials, Username and password used to authenticate the API<\/p>\n\n\n\n<p><strong>Parameters: <\/strong>PARAM tab in Postman is mapped with Parameters fields in X3 as Key-value Pair<\/p>\n\n\n\n\n\n<p><strong>In X3:Below\nCode Snippet to call external API <\/strong><\/p>\n\n\n\n<p>&nbsp; ##Declaration of Variables used in executing\nRestWebservice##<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; LOCAL CHAR YAPI(250),YURI(250),PCOD(100)(1..100),<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; PVAL(100)(1..100),HCOD(100)(1..100),HVAL(100)(1..100)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; LOCAL CLBFILE YMTD,YREQBODY,YRESBODY,RESHEAD(0)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; LOCAL CLBFILE RESBODY<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; LOCAL INTEGER RETVAL<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; ##Declaring Header ,Method and Path of URL\nthrough Code<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; HCOD(1) &nbsp;&nbsp;=&nbsp;\n&#8220;Authorization&#8221;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; HVAL(1) &nbsp;&nbsp;&nbsp;=&nbsp;\n&#8216;&#8221;X3User:UserX3&#8243;&#8216;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; HCOD(2) &nbsp;&nbsp;=&nbsp;\n&#8220;Content-Type&#8221;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; HVAL(2) &nbsp;&nbsp;&nbsp;=&nbsp;\n&#8216;&#8221;application\/json&#8221;&#8216;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; YMTD&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp; &#8216;POST&#8217;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; YAPI&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp; &#8216;CreateID&#8217;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; YURI&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp; &#8216;\/api\/users&#8217;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; YRESBODY =&nbsp;\n&#8221;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; YREQBODY =&nbsp;\n&#8216;{&#8220;name&#8221;: &#8220;Kalam&#8221;,&#8221;job&#8221;:\n&#8220;scientist&#8221;}&#8217;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; ##Call EXEC_REST_WS Method from\nASYRRESTCLI library function<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; RETVAL&nbsp;\n= Func\nASYRRESTCLI.EXEC_REST_WS(YAPI,YMTD,YURI,PCOD,PVAL,HCOD,HVAL,YREQBODY,0,&#8221;,RESHEAD,YRESBODY)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; IF(RETVAL=201)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INFBOX NUM$(YRESBODY)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; ELSIF(RETVAL=500)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INFBOX NUM$(&#8220;CONNECTIVITY\nISSUE!!!&#8221;)&nbsp;&nbsp; <\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; ENDIF<\/p>\n\n\n\n<p><strong>Explanation of\nCode snippet:<\/strong><\/p>\n\n\n\n<p>The header is specified in the Key-value pair, the Header should contain authorization and content-type details. <\/p>\n\n\n\n<p>Assign\nthe variable HCOD(1)- Header code of array index 1 to Authorization.<\/p>\n\n\n\n<p>Assign\nthe variable HVAL(1) -Header variable of array index 1 to username and password\nseparated with Colon.<\/p>\n\n\n\n<p>Assign\nthe variable HCOD(2)- Header code of array index 2 to Content-type.<\/p>\n\n\n\n<p>Assign\nthe variable HVAL(2)- Header variable of array index 2 to application\/Json.<\/p>\n\n\n\n<p>Assign\nthe variable YMTD-Type of Method used&nbsp; to\nstring value &#8220;POST&#8221;<\/p>\n\n\n\n<p>Assign\nthe variable YAPI -REST web service Name to &#8221; CreateID &#8220;<\/p>\n\n\n\n<p>Assign the variable YURI with the remaining part of the URL<\/p>\n\n\n\n<p>just declare the Response body variable <\/p>\n\n\n\n<p>and\nAssign the YREQBODY variable to input<\/p>\n\n\n\n<p>call\nEXEC_REST_WS function from ASYRRESTCLI library with all required parameters and\nwill return status code as integer value which shows success or failure and\nresult json format is stored in YRESBODY Variable.<\/p>\n\n\n\n<p><strong>IMPORTANT\nNOTE:<\/strong><\/p>\n\n\n\n<p>If\nthere is an requirement of sending Username and password directly through code\nwithout passing in REST webservices. Explanation with scenario,<\/p>\n\n\n\n<p>From the Login authentication screen, if it is successful then pass those credentials to the REST web services through code, In that case, the Header variable should contain<\/p>\n\n\n\n<p>Header\nCode HCOD(1) as &#8220;Authorization&#8221; and <\/p>\n\n\n\n<p>Header\nVal HVAL(1) as &#8221; Basic MTcwZWU5MmEyODOTo= &#8220;<\/p>\n\n\n\n<p>String\n&#8220;Basic&#8221; followed by BASE 64 format of Username: Password<\/p>\n\n\n\n<p>Refer\nthe blog for the ASYRRESTCLI function and its parameters to be passed for the\nfunction <\/p>\n\n\n\n<p>&#8220;The narration of function and its parameter used to call an external\/outgoing REST web service from ASYRRESTCLI library&#8221;<\/p>\n\n\n\n<p><strong>Few List of Status\nCode and its description<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>200<\/strong> &#8211; Successful request.<\/li>\n\n\n\n<li><strong>201&nbsp;<\/strong>&#8211; Successful requests and data were created.<\/li>\n\n\n\n<li><strong>204&nbsp;<\/strong>&#8211; Empty Response.<\/li>\n\n\n\n<li><strong>400&nbsp;<\/strong>&#8211; Bad Request. <\/li>\n\n\n\n<li><strong>401<\/strong>&nbsp;&#8211; Unauthorized access<\/li>\n\n\n\n<li><strong>403&nbsp;<\/strong>&#8211; Forbidden, Access denied.<\/li>\n\n\n\n<li><strong>404&nbsp;<\/strong>&#8211; Data not found.<\/li>\n\n\n\n<li><strong>405&nbsp;<\/strong>&#8211; Method Not Allowed or Requested method is not supported.<\/li>\n\n\n\n<li><strong>500&nbsp;<\/strong>&#8211; Internal Server Error.<\/li>\n\n\n\n<li><strong>503<\/strong>&nbsp;&#8211; Service Unavailable.<\/li>\n<\/ul>\n\n\n\n<p>Response from API while executing the code above in X3.<\/p>\n\n\n\n\n\n<p>This blog helps us to understand the mapping of fields from POSTMAN tool to X3 REST web services and code used to call an external API by using EXEC_REST_ES function by passing credentials in header variables.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>About Us<\/strong><\/h2>\n\n\n\n<p>Greytrix \u2013 a globally recognized and one of the oldest Sage Development Partners is a one-stop solution provider for Sage ERP and Sage CRM organizational needs. Being acknowledged and rewarded for multi-man years of experience and expertise, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third-party add-on development, and implementation competence.<\/p>\n\n\n\n<p id=\"block-28013e99-0882-44c6-b705-7b16c85053b2\">Greytrix&nbsp;has some unique integration solutions developed for&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-crm\/\">Sage CRM<\/a>&nbsp;with Sage ERPs&nbsp;namely&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-x3-erp\/\">Sage X3<\/a>,&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-intacct\/\">Sage Intacct<\/a>,&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-100-erp\/\">Sage 100<\/a>,&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-500-erp\/\">Sage 500<\/a>,&nbsp;and&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-300-erp\/\">Sage 300<\/a>. We also offer best-in-class&nbsp;Sage ERP&nbsp;and&nbsp;Sage CRM&nbsp;customization and development services&nbsp;to&nbsp;Business&nbsp;Partners,&nbsp;End&nbsp;Users, and Sage PSG worldwide. Greytrix&nbsp;helps in&nbsp;the migration of Sage CRM from&nbsp;Salesforce | ACT! | SalesLogix | Goldmine | Sugar CRM | Maximizer. Our Sage CRM Product Suite includes&nbsp;addons like&nbsp;&nbsp;Greytrix Business Manager,&nbsp;Sage CRM Project Manager,&nbsp;Sage CRM Resource Planner,&nbsp;Sage CRM Contract Manager,&nbsp;Sage CRM Event Manager,&nbsp;Sage CRM Budget Planner,&nbsp;Gmail Integration,&nbsp;Sage CRM Mobile Service Signature,&nbsp;Sage CRM CTI Framework.<\/p>\n\n\n\n<p id=\"block-4bc42a09-fb13-4598-8137-ce5f7b91ce28\">Greytrix is a recognized&nbsp;Sage Champion Partner&nbsp;for GUMU&#x2122; Sage X3 \u2013 Sage CRM integration listed on&nbsp;<a href=\"https:\/\/www.sage.com\/marketplace\/asb_ListingDetail?listingId=a1h24000007PC3aAAG\" target=\"_blank\" rel=\"noreferrer noopener\">Sage Marketplace<\/a>&nbsp;and Sage CRM \u2013 Sage Intacct integration listed on&nbsp;<a href=\"https:\/\/marketplace.intacct.com\/MPListing?lid=a2D0H000007kiHyUAI\" target=\"_blank\" rel=\"noreferrer noopener\">Sage Intacct Marketplace<\/a>. The&nbsp;<a href=\"https:\/\/www.greytrix.com\/gumu\/\" target=\"_blank\" rel=\"noreferrer noopener\">GUMU&#x2122; Cloud framework<\/a>&nbsp;by Greytrix forms the backbone of cloud integrations that are managed in real-time for the processing and execution of application programs at the click of a button.<\/p>\n\n\n\n<p id=\"block-76376301-1c3e-4250-8a09-727595a606f0\">For more information on our integration solutions, please contact us at&nbsp;<a href=\"mailto:sage@greytrix.com\">sage@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We come across the scenario, where we will use POSTMAN software tool to examine the working of external API. Postman is a simple GUI for sending HTTP requests and viewing responses. REST services are available in Sage x3 which returns data in a JSON format. In this blog, we are going to visualize the mapping\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/2020\/07\/27\/how-to-call-an-api-through-postman-tool-and-map-with-x3-fields\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,4,2796,11],"tags":[3027,3026,3029,3028,2662,1822,1839],"class_list":["post-20255","post","type-post","status-publish","format-standard","hentry","category-sage-erp-x3","category-faq","category-technical","category-tips","tag-asyrestcli","tag-exec_rest_ws","tag-post-method","tag-postman","tag-rest-web-service-from-sage-x3","tag-sage-x3","tag-sage-x3-blogs"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts\/20255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/comments?post=20255"}],"version-history":[{"count":8,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts\/20255\/revisions"}],"predecessor-version":[{"id":30265,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts\/20255\/revisions\/30265"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/media?parent=20255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/categories?post=20255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/tags?post=20255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}