{"id":11663,"date":"2022-02-09T11:15:19","date_gmt":"2022-02-09T17:15:19","guid":{"rendered":"https:\/\/www.mrc-productivity.com\/docs\/?post_type=ht_kb&#038;p=11663"},"modified":"2023-08-07T10:01:38","modified_gmt":"2023-08-07T15:01:38","slug":"using-a-maintainer-to-call-web-services-api","status":"publish","type":"ht_kb","link":"https:\/\/www.mrc-productivity.com\/docs\/knowledge-base\/using-a-maintainer-to-call-web-services-api","title":{"rendered":"Using a Maintainer to call Web Services API"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Overview<\/h3>\n\n\n\n<p>This enhancement allows developers to call web service endpoints from m-Power maintainer applications on add\/update\/delete actions. <\/p>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-alert\">This feature only applies to bootstrap Data List with Web Form and Single Web Form templates.<\/p>\n\n\n\n<p>This enhancement utilizes both the dictionary level web service endpoint configuration as well as the maintainer workflow designer to fully configure and customize the web service integration.<\/p>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">The configuration of authentication methods and dictionary sign on for read-only web services (documented <a href=\"https:\/\/www.mrc-productivity.com\/docs\/knowledge-base\/using-web-services\">here<\/a>) also applies to maintenance web service call<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"baseURL\">Configure Web Service at Dictionary Level<\/h3>\n\n\n\n<p>Configure the web service at the dictionary admin level just as you would for a read-only web service. There is no need to provide a sample body or configure web service fields for a web service endpoint that is write only (POST, PUT, DELETE). You can leave those tabs in the interface blank. Navigate to Admin -&gt; Web Services -&gt; Web Service Endpoints. Then &#8220;Register New Web Service&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"900\" height=\"507\" src=\"https:\/\/www.mrc-productivity.com\/docs\/images\/image-19-900x507.png\" alt=\"\" class=\"wp-image-11683\" srcset=\"https:\/\/www.mrc-productivity.com\/docs\/images\/image-19-900x507.png 900w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-19-300x169.png 300w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-19-150x85.png 150w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-19-768x433.png 768w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-19-50x28.png 50w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-19-60x34.png 60w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-19-100x56.png 100w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-19.png 1439w\" sizes=\"(max-width: 900px) 100vw, 900px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"authMeth\">Create Maintainer that will Invoke Web Service<\/h3>\n\n\n\n<p>Create your maintainer just as you would any other normal application. <\/p>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">Some users don&#8217;t want m-Power to write to the database when calling an API. If this applies to you, you should set the Skip Database Actions options to Yes in your Maintainer&#8217;s Application Property window.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"514\" height=\"121\" src=\"https:\/\/www.mrc-productivity.com\/docs\/images\/image-14.png\" alt=\"\" class=\"wp-image-11678\" srcset=\"https:\/\/www.mrc-productivity.com\/docs\/images\/image-14.png 514w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-14-300x71.png 300w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-14-150x35.png 150w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-14-50x12.png 50w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-14-60x14.png 60w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-14-100x24.png 100w\" sizes=\"(max-width: 514px) 100vw, 514px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"basic\">Invoke API via Workflow<\/h3>\n\n\n\n<p>Next, open the Workflow designer in the maintainer you just created. Create a conditional node to set whether you want to call your web service on add or update or delete.<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"561\" height=\"424\" src=\"https:\/\/www.mrc-productivity.com\/docs\/images\/image-15.png\" alt=\"\" class=\"wp-image-11679\" srcset=\"https:\/\/www.mrc-productivity.com\/docs\/images\/image-15.png 561w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-15-300x227.png 300w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-15-150x113.png 150w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-15-50x38.png 50w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-15-60x45.png 60w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-15-100x76.png 100w\" sizes=\"(max-width: 561px) 100vw, 561px\" \/><\/figure>\n\n\n\n<p>Select the Conditional option of &#8220;Check the Action Mode (Add\/Update\/Delete)&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"413\" height=\"206\" src=\"https:\/\/www.mrc-productivity.com\/docs\/images\/image-16.png\" alt=\"\" class=\"wp-image-11680\" srcset=\"https:\/\/www.mrc-productivity.com\/docs\/images\/image-16.png 413w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-16-300x150.png 300w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-16-150x75.png 150w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-16-50x25.png 50w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-16-60x30.png 60w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-16-100x50.png 100w\" sizes=\"(max-width: 413px) 100vw, 413px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Name the condition, and select the appropriate action. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"802\" height=\"360\" src=\"https:\/\/www.mrc-productivity.com\/docs\/images\/image-17.png\" alt=\"\" class=\"wp-image-11681\" srcset=\"https:\/\/www.mrc-productivity.com\/docs\/images\/image-17.png 802w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-17-300x135.png 300w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-17-150x67.png 150w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-17-768x345.png 768w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-17-50x22.png 50w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-17-60x27.png 60w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-17-100x45.png 100w\" sizes=\"(max-width: 802px) 100vw, 802px\" \/><\/figure>\n\n\n\n<p>Add an action \u201cIf True\u201d to the condition. Use the \u201cCall an external API\u201d action type. The API configuration modal provides a list of all the web service endpoints configured at the dictionary level. Select the appropriate web service you created earlier in this document:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"800\" height=\"437\" src=\"https:\/\/www.mrc-productivity.com\/docs\/images\/image-8.png\" alt=\"\" class=\"wp-image-11672\" srcset=\"https:\/\/www.mrc-productivity.com\/docs\/images\/image-8.png 800w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-8-300x164.png 300w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-8-150x82.png 150w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-8-768x420.png 768w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-8-50x27.png 50w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-8-60x33.png 60w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-8-100x55.png 100w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"800\" height=\"656\" src=\"https:\/\/www.mrc-productivity.com\/docs\/images\/image-9.png\" alt=\"\" class=\"wp-image-11673\" srcset=\"https:\/\/www.mrc-productivity.com\/docs\/images\/image-9.png 800w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-9-300x246.png 300w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-9-150x123.png 150w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-9-768x630.png 768w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-9-50x41.png 50w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-9-60x49.png 60w, https:\/\/www.mrc-productivity.com\/docs\/images\/image-9-100x82.png 100w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>In the image above, note the API Message Body, this is where you configure the message body to be posted to your web service endpoint. The interface allows for JSON or URL encoded form content types (shown above). The API dialog will attempt to construct a default message body using all the fields from the maintainer. It is likely not exactly what you want to POST but serves as an example or starting point to construct your message body. You can change any part of this body as needed to match the parameter names expected by your web service or remove fields not needed. The \u201cMXXXX.fieldname.type\u201d strings are field substitutions that will be replaced at runtime with values submitted from the app\/webform.&nbsp; <\/p>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">If you need help creating the field substitutions, just type the open square bracket key [ and select from the list of maintainer fields. It will insert the appropriate substitution for you.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Running the Application<\/h3>\n\n\n\n<p>At runtime, the user will interact with maintainer just like they would any standard m-Power built application. However, when the user submits the record, based on the rules found in the Workflow designer, the app will trigger the API call as specified above. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview This enhancement allows developers to call web service endpoints from m-Power maintainer applications on add\/update\/delete actions. This enhancement utilizes both the dictionary level web service endpoint configuration as well as the maintainer workflow designer to fully configure and customize the web service integration. Configure Web Service at Dictionary Level&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[],"ht-kb-tag":[281],"class_list":["post-11663","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_tag-web-services"],"_links":{"self":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/11663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/comments?post=11663"}],"version-history":[{"count":6,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/11663\/revisions"}],"predecessor-version":[{"id":13127,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/11663\/revisions\/13127"}],"wp:attachment":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/media?parent=11663"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-category?post=11663"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-tag?post=11663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}