<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://dataflex.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mwpmullan</id>
	<title>DataFlex Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://dataflex.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mwpmullan"/>
	<link rel="alternate" type="text/html" href="https://dataflex.wiki/index.php?title=Special:Contributions/Mwpmullan"/>
	<updated>2026-05-03T02:13:52Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://dataflex.wiki/index.php?title=Consuming_RESTful_Services_in_DataFlex&amp;diff=3375</id>
		<title>Consuming RESTful Services in DataFlex</title>
		<link rel="alternate" type="text/html" href="https://dataflex.wiki/index.php?title=Consuming_RESTful_Services_in_DataFlex&amp;diff=3375"/>
		<updated>2020-12-05T16:42:51Z</updated>

		<summary type="html">&lt;p&gt;Mwpmullan: Compiler bug in df20 on example.  added PointerToString&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:The RESTTest view.jpg|thumb|100px|The RESTTest view]]&lt;br /&gt;
&lt;br /&gt;
To consume (be a client of) a web service we are going to need to be able to make HTTP requests and receive their responses. The way of doing this in DataFlex is by using the [https://docs.dataaccess.com/dataflexhelp/index.htm#t=mergedProjects%2FVDFClassRef%2FcHttpTransfer.htm cHttpTransfer class] (or its sub-classes: the [https://docs.dataaccess.com/dataflexhelp/index.htm#t=mergedProjects%2FVDFClassRef%2FcJsonHttpTransfer.htm cJsonHttpTransfer class] and the [https://docs.dataaccess.com/dataflexhelp/index.htm#t=mergedProjects%2FVDFClassRef%2FcXmlHttpTransfer.htm cXmlHttpTransfer class]).&lt;br /&gt;
&lt;br /&gt;
We will also want to make use of objects of the [https://docs.dataaccess.com/dataflexhelp/index.htm#t=mergedProjects%2FVDFClassRef%2FcJsonObject.htm&amp;amp;rhsearch=cJsonObject&amp;amp;rhhlterm=cJsonObject&amp;amp;rhsyns=%20 cJsonObject class] to handle responses and, in cases where we wish to create or update data, handle our request contents.&lt;br /&gt;
&lt;br /&gt;
===Sample Test View===&lt;br /&gt;
&lt;br /&gt;
The following view object code will provide an example and test mechanism for calling most RESTful services. In the DataFlex Studio you should be able to copy the code below and paste it into a Windows view:&lt;br /&gt;
&lt;br /&gt;
*File --&amp;gt; New --&amp;gt; View / Report --&amp;gt; Data Entry View&lt;br /&gt;
*Name the file: &amp;quot;&#039;&#039;&#039;RESTTest&#039;&#039;&#039;&amp;quot;&lt;br /&gt;
*Double click on the view to switch to the code editor&lt;br /&gt;
*Select all (Ctrl-A), then paste in the code below, overwriting what is there&lt;br /&gt;
*Compile and run (F5)&lt;br /&gt;
*In the program, do View --&amp;gt; RESTTest to open the view and see it in action (just click the &amp;quot;Send&amp;quot; button with the defaults for a first look to check that all is working properly).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;RESTTest.vw&#039;&#039;&#039;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;vdf&amp;quot;&amp;gt;&lt;br /&gt;
Use Windows.pkg&lt;br /&gt;
Use DFClient.pkg&lt;br /&gt;
Use cTextEdit.pkg&lt;br /&gt;
Use cHttpTransfer.pkg&lt;br /&gt;
Use cJsonObject.pkg&lt;br /&gt;
Use WinUuid.pkg&lt;br /&gt;
 &lt;br /&gt;
Deferred_View Activate_oRESTTest for ;&lt;br /&gt;
Object oRESTTest is a dbView&lt;br /&gt;
    Set Border_Style to Border_Thick&lt;br /&gt;
    Set Size to 373 350&lt;br /&gt;
    Set Location to 2 2&lt;br /&gt;
    Set Label to &amp;quot;REST Tester&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
    // This is the HTTP object which we will use to make all our calls.&lt;br /&gt;
    // It is augmented to store received data in a UChar array property so does&lt;br /&gt;
    // *not* suffer from string length limitations (see: Set_Argument_Size).&lt;br /&gt;
    //&lt;br /&gt;
    // You should always send Reset of this object as the first thing you do&lt;br /&gt;
    // making a call.&lt;br /&gt;
    Object oHttp is a cHttpTransfer&lt;br /&gt;
        Property UChar[] pucaData&lt;br /&gt;
        Property String  psContentType&lt;br /&gt;
     &lt;br /&gt;
        Procedure OnDataReceived String sContentType String sData&lt;br /&gt;
            UChar[] ucaData&lt;br /&gt;
             &lt;br /&gt;
            Get pucaData                                            to ucaData&lt;br /&gt;
            Move (AppendArray(ucaData, StringToUCharArray(sData)))  to ucaData&lt;br /&gt;
            Set pucaData                                            to ucaData&lt;br /&gt;
            Set psContentType                                       to sContentType&lt;br /&gt;
        End_Procedure&lt;br /&gt;
         &lt;br /&gt;
        Procedure Reset&lt;br /&gt;
            UChar[] empty&lt;br /&gt;
             &lt;br /&gt;
            Set pucaData        to empty&lt;br /&gt;
            Set psContentType   to &amp;quot;&amp;quot;&lt;br /&gt;
            Set peTransferFlags to 0&lt;br /&gt;
            Set psAcceptTypes   to &amp;quot;*&amp;quot;&lt;br /&gt;
            Send ClearHeaders&lt;br /&gt;
        End_Procedure&lt;br /&gt;
     &lt;br /&gt;
    End_Object&lt;br /&gt;
 &lt;br /&gt;
    // The MakeCall procedure is what does all the work - everything else is &lt;br /&gt;
    // just set up:&lt;br /&gt;
    Procedure MakeCall&lt;br /&gt;
        String  sPath sVerb sAuth sToken sUUID&lt;br /&gt;
        Address pReq pCreds&lt;br /&gt;
        Integer iSize iOK iStatus&lt;br /&gt;
        UChar[] ucaReq ucaResp&lt;br /&gt;
        Handle  hoReq hoResp&lt;br /&gt;
        Boolean bOK bSecure bUUID bOnlyJSON&lt;br /&gt;
         &lt;br /&gt;
        Send Reset          of oHttp  // Important!&lt;br /&gt;
         &lt;br /&gt;
        Set Value of oReceivedJSON      to &amp;quot;&amp;quot;  // Make sure to clear out any&lt;br /&gt;
        Set Value of oRespStatus        to &amp;quot;&amp;quot;  // old results from these&lt;br /&gt;
         &lt;br /&gt;
        Set psRemoteHost    of oHttp    to (Value(oHost))&lt;br /&gt;
        Set piRemotePort    of oHttp    to (Value(oPort))&lt;br /&gt;
 &lt;br /&gt;
        Get Value of oAuthType          to sAuth&lt;br /&gt;
        Get Value of oPath              to sPath&lt;br /&gt;
        Get Value of oVerb              to sVerb&lt;br /&gt;
        Get Checked_State of oSecure    to bSecure&lt;br /&gt;
        Get Checked_State of oUseUUID   to bUUID&lt;br /&gt;
        Get Checked_State of oOnlyJSON  to bOnlyJSON&lt;br /&gt;
         &lt;br /&gt;
        If bSecure Begin&lt;br /&gt;
            Set peTransferFlags of oHttp to ifSecure&lt;br /&gt;
        End&lt;br /&gt;
         &lt;br /&gt;
        // Usually not used&lt;br /&gt;
        If bUUID Begin&lt;br /&gt;
            Move (RandomHexUUID())                                      to sUUID&lt;br /&gt;
            Get AddHeader of oHttp &amp;quot;client-request-id&amp;quot; sUUID            to iOK&lt;br /&gt;
            Get AddHeader of oHttp &amp;quot;return-client-request-id&amp;quot; &amp;quot;true&amp;quot;    to iOK&lt;br /&gt;
        End&lt;br /&gt;
         &lt;br /&gt;
        // Usually not used&lt;br /&gt;
        If bOnlyJSON Begin&lt;br /&gt;
            Set psAcceptTypes of oHttp  to &amp;quot;application/json&amp;quot;&lt;br /&gt;
        End&lt;br /&gt;
         &lt;br /&gt;
        If (sAuth = &amp;quot;Basic&amp;quot;) Begin&lt;br /&gt;
            Move (Value(oCreds) + &amp;quot;:&amp;quot; + Value(oPassword)) to sToken&lt;br /&gt;
            Move (Base64Encode(AddressOf(sToken), Length(sToken))) to pCreds&lt;br /&gt;
            Move (PointerToString(pCreds))  to sToken &lt;br /&gt;
            Move (Free(pCreds)) to bOK&lt;br /&gt;
            Get AddHeader of oHttp &amp;quot;Authorization&amp;quot; (&amp;quot;Basic&amp;quot; * sToken) to bOK&lt;br /&gt;
        End&lt;br /&gt;
        Else If (sAuth = &amp;quot;Bearer&amp;quot;) Begin&lt;br /&gt;
            Get Value of oCreds to sToken&lt;br /&gt;
            Get AddHeader of oHttp &amp;quot;Authorization&amp;quot; (&amp;quot;Bearer&amp;quot; * sToken) to iOK&lt;br /&gt;
        End&lt;br /&gt;
         &lt;br /&gt;
        // If we are doing a POST, PUT or PATCH, we need to assemble the JSON&lt;br /&gt;
        // we are going to send with the request&lt;br /&gt;
        If ((sVerb = &amp;quot;GET&amp;quot;) or (sVerb = &amp;quot;DELETE&amp;quot;)) Begin&lt;br /&gt;
            Move 0 to pReq&lt;br /&gt;
            Move 0 to iSize&lt;br /&gt;
        End&lt;br /&gt;
        Else Begin&lt;br /&gt;
             &lt;br /&gt;
            If (Value(oSendJSON) = &amp;quot;&amp;quot;) Begin&lt;br /&gt;
                Send Info_Box (&amp;quot;For&amp;quot; * sVerb * &amp;quot;you must enter valid JSON to send&amp;quot;) &amp;quot;Error&amp;quot;&lt;br /&gt;
                Procedure_Return&lt;br /&gt;
            End&lt;br /&gt;
             &lt;br /&gt;
            Get Create (RefClass(cJsonObject)) to hoReq          // Created&lt;br /&gt;
            Get ParseString of hoReq (Value(oSendJSON)) to bOK&lt;br /&gt;
             &lt;br /&gt;
            If not bOK Begin&lt;br /&gt;
                Send Info_Box (&amp;quot;Invalid input JSON:&amp;quot; * psParseError(hoReq)) &amp;quot;Error&amp;quot;&lt;br /&gt;
                Send Destroy of hoReq                            // Destroy before&lt;br /&gt;
                Procedure_Return                                 // exiting&lt;br /&gt;
            End&lt;br /&gt;
             &lt;br /&gt;
            Get StringifyUtf8 of hoReq  to ucaReq&lt;br /&gt;
            Send Destroy of hoReq                                // or Destroy here&lt;br /&gt;
             &lt;br /&gt;
            Move (AddressOf(ucaReq))    to pReq&lt;br /&gt;
            Move (SizeOfArray(ucaReq))  to iSize&lt;br /&gt;
            Get AddHeader of oHttp &amp;quot;Content-Type&amp;quot; &amp;quot;application/json&amp;quot; to iOK&lt;br /&gt;
        End&lt;br /&gt;
         &lt;br /&gt;
        Get HttpVerbAddrRequest of oHttp sPath pReq iSize False sVerb to iOK&lt;br /&gt;
         &lt;br /&gt;
        If iOK Begin&lt;br /&gt;
            Get ResponseStatusCode of oHttp to iStatus&lt;br /&gt;
            Set Value of oRespStatus to iStatus&lt;br /&gt;
            Get pucaData of oHttp to ucaResp&lt;br /&gt;
            &lt;br /&gt;
            // Do we have some response?&lt;br /&gt;
            If (SizeOfArray(ucaResp)) Begin&lt;br /&gt;
                Get Create (RefClass(cJsonObject))  to hoResp // Created&lt;br /&gt;
                Set peWhiteSpace of hoResp          to jpWhitespace_Pretty&lt;br /&gt;
                Set pbEscapeForwardSlash of hoResp  to False&lt;br /&gt;
                Get ParseUtf8 of hoResp ucaResp     to bOK&lt;br /&gt;
                &lt;br /&gt;
                If bOK ;&lt;br /&gt;
                    Set Value of oReceivedJSON      to (Stringify(hoResp))&lt;br /&gt;
                Else ;&lt;br /&gt;
                    Send Info_Box (&amp;quot;Invalid JSON received,&amp;quot; * psParseError(hoResp)) &amp;quot;Error&amp;quot;                &lt;br /&gt;
                &lt;br /&gt;
                Send Destroy of hoResp                       // Destroyed&lt;br /&gt;
            End&lt;br /&gt;
            &lt;br /&gt;
            If not ((iStatus &amp;gt;= 200) and (iStatus &amp;lt; 300)) ;&lt;br /&gt;
                Send Info_Box (&amp;quot;Http status:&amp;quot; * String(iStatus)) &amp;quot;Error&amp;quot;&lt;br /&gt;
        End&lt;br /&gt;
        Else Begin&lt;br /&gt;
            Send Info_Box &amp;quot;HTTP request failed&amp;quot; &amp;quot;Error&amp;quot;&lt;br /&gt;
        End&lt;br /&gt;
         &lt;br /&gt;
    End_Procedure&lt;br /&gt;
     &lt;br /&gt;
    // By default the view is set up to call &lt;br /&gt;
    // http://jsonplaceholder.typicode.com/posts on port 80 (insecure), which is&lt;br /&gt;
    // a dummy RESTful service offering a range of calls you can make.&lt;br /&gt;
    // See: http://jsonplaceholder.typicode.com for the list. Calls to it don&#039;t &lt;br /&gt;
    // actually change anything, but will provide realistic responses.&lt;br /&gt;
    //&lt;br /&gt;
    // It works both with HTTP and HTTPS (secure).&lt;br /&gt;
    //&lt;br /&gt;
    // Useful for testing only.&lt;br /&gt;
    //&lt;br /&gt;
    // Change the various values to call the service of your choice.&lt;br /&gt;
 &lt;br /&gt;
    Object oHost is a Form&lt;br /&gt;
        Set Size to 12 293&lt;br /&gt;
        Set Location to 4 55&lt;br /&gt;
        Set Label to &amp;quot;Host:&amp;quot;&lt;br /&gt;
        Set Label_Justification_Mode to JMode_Right&lt;br /&gt;
        Set Label_Col_Offset to 5&lt;br /&gt;
        Set peAnchors to anTopLeftRight&lt;br /&gt;
        Set Value to &amp;quot;jsonplaceholder.typicode.com&amp;quot;&lt;br /&gt;
        Set psToolTip to &amp;quot;The host name or IP address of the server to call&amp;quot;&lt;br /&gt;
    End_Object&lt;br /&gt;
 &lt;br /&gt;
    Object oPort is a Form&lt;br /&gt;
        Set Size to 12 22&lt;br /&gt;
        Set Location to 18 55&lt;br /&gt;
        Set Label to &amp;quot;Port:&amp;quot;&lt;br /&gt;
        Set Label_Justification_Mode to JMode_Right&lt;br /&gt;
        Set Label_Col_Offset to 5&lt;br /&gt;
        Set Value to &amp;quot;80&amp;quot;&lt;br /&gt;
        Set Form_Datatype to 0&lt;br /&gt;
        Set psToolTip to &amp;quot;The port to use: usually 80 for insecure, 443 for secure&amp;quot;&lt;br /&gt;
    End_Object&lt;br /&gt;
 &lt;br /&gt;
    // Most &amp;quot;real&amp;quot; services will require a secure (HTTPS) connection&lt;br /&gt;
    Object oSecure is a CheckBox&lt;br /&gt;
        Set Size to 10 50&lt;br /&gt;
        Set Location to 20 104&lt;br /&gt;
        Set Label to &amp;quot;Secure&amp;quot;&lt;br /&gt;
        Set psToolTip to &amp;quot;Use secure HTTP (HTTPS)&amp;quot;&lt;br /&gt;
         &lt;br /&gt;
        Procedure OnChange&lt;br /&gt;
            Boolean bChecked&lt;br /&gt;
         &lt;br /&gt;
            Get Checked_State to bChecked&lt;br /&gt;
             &lt;br /&gt;
            Set Value of oPort to (If(bChecked, rpHttpSSL, rpHttp))&lt;br /&gt;
        End_Procedure&lt;br /&gt;
     &lt;br /&gt;
    End_Object&lt;br /&gt;
 &lt;br /&gt;
    // Some services may require a request UUID (generally leave it unchecked)&lt;br /&gt;
    Object oUseUUID is a CheckBox&lt;br /&gt;
        Set Size to 10 50&lt;br /&gt;
        Set Location to 20 150&lt;br /&gt;
        Set Label to &amp;quot;Use request UUID&amp;quot;&lt;br /&gt;
        Set psToolTip to &amp;quot;Add a UUID to the request Headers&amp;quot;&lt;br /&gt;
    End_Object&lt;br /&gt;
 &lt;br /&gt;
    // If the service reqires this, you can check this box to ensure that the&lt;br /&gt;
    // the HTTP object will only accep JSON (gererally leave it unchecked)&lt;br /&gt;
    Object oOnlyJSON is a CheckBox&lt;br /&gt;
        Set Size to 10 50&lt;br /&gt;
        Set Location to 20 235&lt;br /&gt;
        Set Label to &amp;quot;Only accept JSON&amp;quot;&lt;br /&gt;
        Set psToolTip to &amp;quot;Only accept JSON responses&amp;quot;&lt;br /&gt;
    End_Object&lt;br /&gt;
 &lt;br /&gt;
    // The path on the server to call.&lt;br /&gt;
    //&lt;br /&gt;
    // The default jsonplaceholder service has &amp;quot;posts&amp;quot;, &amp;quot;todos&amp;quot;, &amp;quot;comments&amp;quot;,&lt;br /&gt;
    // &amp;quot;albums&amp;quot;, &amp;quot;photos&amp;quot; and &amp;quot;users&amp;quot;.&lt;br /&gt;
    //&lt;br /&gt;
    // For the various options, see: http://jsonplaceholder.typicode.com/.&lt;br /&gt;
    Object oPath is a Form&lt;br /&gt;
        Set Size to 12 293&lt;br /&gt;
        Set Location to 33 55&lt;br /&gt;
        Set Label to &amp;quot;Path:&amp;quot;&lt;br /&gt;
        Set Label_Justification_Mode to JMode_Right&lt;br /&gt;
        Set Label_Col_Offset to 5&lt;br /&gt;
        Set peAnchors to anTopLeftRight&lt;br /&gt;
        Set Value to &amp;quot;posts&amp;quot;&lt;br /&gt;
        Set psToolTip to &amp;quot;The path on the server to call&amp;quot;&lt;br /&gt;
    End_Object&lt;br /&gt;
 &lt;br /&gt;
    Object oVerb is a ComboForm&lt;br /&gt;
        Set Size to 12 49&lt;br /&gt;
        Set Location to 48 55&lt;br /&gt;
        Set Label_Col_Offset to 5&lt;br /&gt;
        Set Label_Justification_Mode to JMode_Right&lt;br /&gt;
        Set Combo_Sort_State to False&lt;br /&gt;
        Set Allow_Blank_State to False&lt;br /&gt;
        Set Value to &amp;quot;GET&amp;quot;&lt;br /&gt;
        Set Label to &amp;quot;Verb:&amp;quot;&lt;br /&gt;
        Set psToolTip to &amp;quot;The HTTP verb to make the call with&amp;quot;&lt;br /&gt;
       &lt;br /&gt;
        Procedure Combo_Fill_List&lt;br /&gt;
            Send Combo_Add_Item &amp;quot;GET&amp;quot;&lt;br /&gt;
            Send Combo_Add_Item &amp;quot;POST&amp;quot;&lt;br /&gt;
            Send Combo_Add_Item &amp;quot;PUT&amp;quot;&lt;br /&gt;
            Send Combo_Add_Item &amp;quot;PATCH&amp;quot;&lt;br /&gt;
            Send Combo_Add_Item &amp;quot;DELETE&amp;quot;&lt;br /&gt;
        End_Procedure&lt;br /&gt;
       &lt;br /&gt;
        Procedure OnChange&lt;br /&gt;
            String sValue&lt;br /&gt;
         &lt;br /&gt;
            Get Value to sValue&lt;br /&gt;
            Set Enabled_State of oSendJSON to ((sValue &amp;lt;&amp;gt; &amp;quot;GET&amp;quot;) and (sValue &amp;lt;&amp;gt; &amp;quot;DELETE&amp;quot;))&lt;br /&gt;
        End_Procedure&lt;br /&gt;
       &lt;br /&gt;
    End_Object&lt;br /&gt;
 &lt;br /&gt;
    // This controls what kind of authentication the call will use. That can be&lt;br /&gt;
    // &amp;quot;None&amp;quot;, &amp;quot;Basic&amp;quot; (username and password) or &amp;quot;Bearer&amp;quot; (a &amp;quot;Bearer&amp;quot; token&lt;br /&gt;
    // will be passed in the &amp;quot;Authentication&amp;quot; HTTP header). It dynamically&lt;br /&gt;
    // manipulates the oCreds and oPassword objects depending on what type of&lt;br /&gt;
    // authentication you are using.&lt;br /&gt;
    Object oAuthType is a ComboForm&lt;br /&gt;
        Set Size to 12 42&lt;br /&gt;
        Set Location to 48 189&lt;br /&gt;
        Set Label to &amp;quot;Authentication Type:&amp;quot;&lt;br /&gt;
        Set Label_Col_Offset to 5&lt;br /&gt;
        Set Label_Justification_Mode to JMode_Right&lt;br /&gt;
        Set Combo_Sort_State to False&lt;br /&gt;
        Set Allow_Blank_State to False&lt;br /&gt;
        Set Value to &amp;quot;None&amp;quot;&lt;br /&gt;
        Set psToolTip to &amp;quot;The authentication type to use for the call&amp;quot;&lt;br /&gt;
       &lt;br /&gt;
       Procedure Combo_Fill_List&lt;br /&gt;
            Send Combo_Add_Item &amp;quot;None&amp;quot;&lt;br /&gt;
            Send Combo_Add_Item &amp;quot;Basic&amp;quot;&lt;br /&gt;
            Send Combo_Add_Item &amp;quot;Bearer&amp;quot;&lt;br /&gt;
        End_Procedure&lt;br /&gt;
       &lt;br /&gt;
        Procedure OnChange&lt;br /&gt;
            String sValue&lt;br /&gt;
         &lt;br /&gt;
            Get Value to sValue&lt;br /&gt;
             &lt;br /&gt;
            If (sValue = &amp;quot;Basic&amp;quot;) Begin&lt;br /&gt;
                Set Label of oCreds to &amp;quot;User Name:&amp;quot;&lt;br /&gt;
                Set Enabled_State of oCreds to True&lt;br /&gt;
                Set Visible_State of oCreds to True&lt;br /&gt;
                Set Enabled_State of oPassword to True&lt;br /&gt;
                Set Visible_State of oPassword to True&lt;br /&gt;
                Set psToolTip of oCreds to &amp;quot;The username to make the call with&amp;quot;&lt;br /&gt;
            End&lt;br /&gt;
            Else If (sValue = &amp;quot;Bearer&amp;quot;) Begin&lt;br /&gt;
                Set Label of oCreds to &amp;quot;Token:&amp;quot;&lt;br /&gt;
                Set Enabled_State of oCreds to True&lt;br /&gt;
                Set Visible_State of oCreds to True&lt;br /&gt;
                Set Enabled_State of oPassword to False&lt;br /&gt;
                Set Visible_State of oPassword to False&lt;br /&gt;
                Set psToolTip of oCreds to &#039;The &amp;quot;bearer token&amp;quot; to make the call with&#039;&lt;br /&gt;
            End&lt;br /&gt;
            Else Begin&lt;br /&gt;
                Set Label of oCreds to &amp;quot;User Name:&amp;quot;&lt;br /&gt;
                Set Enabled_State of oCreds to False&lt;br /&gt;
                Set Visible_State of oCreds to False&lt;br /&gt;
                Set Enabled_State of oPassword to False&lt;br /&gt;
                Set Visible_State of oPassword to False&lt;br /&gt;
            End&lt;br /&gt;
             &lt;br /&gt;
        End_Procedure&lt;br /&gt;
       &lt;br /&gt;
    End_Object&lt;br /&gt;
     &lt;br /&gt;
    // Used both for username (if using Basic Auth) and the bearer token (if&lt;br /&gt;
    // using Bearer Auth).&lt;br /&gt;
    Object oCreds is a Form&lt;br /&gt;
        Set Size to 12 158&lt;br /&gt;
        Set Location to 63 189&lt;br /&gt;
        Set Label to &amp;quot;User name:&amp;quot;&lt;br /&gt;
        Set Label_Col_Offset to 5&lt;br /&gt;
        Set Label_Justification_Mode to JMode_Right&lt;br /&gt;
        Set Visible_State to False&lt;br /&gt;
        Set Enabled_State to False&lt;br /&gt;
        Set peAnchors to anTopLeftRight&lt;br /&gt;
        Set psToolTip to &amp;quot;The username to make the call with&amp;quot;&lt;br /&gt;
    End_Object&lt;br /&gt;
 &lt;br /&gt;
    // The password if using basic auth.&lt;br /&gt;
    Object oPassword is a Form&lt;br /&gt;
        Set Size to 12 158&lt;br /&gt;
        Set Location to 78 189&lt;br /&gt;
        Set Label to &amp;quot;Password:&amp;quot;&lt;br /&gt;
        Set Label_Col_Offset to 5&lt;br /&gt;
        Set Label_Justification_Mode to JMode_Right&lt;br /&gt;
        Set Password_State to True&lt;br /&gt;
        Set Visible_State to False&lt;br /&gt;
        Set Enabled_State to False&lt;br /&gt;
        Set peAnchors to anTopLeftRight&lt;br /&gt;
        Set psToolTip to &amp;quot;The password to make the call with&amp;quot;&lt;br /&gt;
    End_Object&lt;br /&gt;
 &lt;br /&gt;
    // You enter the JSON to make your call (POST,PUT and PATCH only) with here.&lt;br /&gt;
    Object oSendJSON is a cTextEdit&lt;br /&gt;
        Set Size to 106 340&lt;br /&gt;
        Set Location to 98 7&lt;br /&gt;
        Set Label to &amp;quot;JSON to send:&amp;quot;&lt;br /&gt;
        Set peAnchors to anTopLeftRight&lt;br /&gt;
        Set Enabled_State to False&lt;br /&gt;
        Set psToolTip to &amp;quot;JSON to pass with the call (POST, PUT amd PATCH only)&amp;quot;&lt;br /&gt;
    End_Object&lt;br /&gt;
 &lt;br /&gt;
    // Clicking this is what sends your call.&lt;br /&gt;
    Object oSendBtn is a Button&lt;br /&gt;
        Set Location to 211 7&lt;br /&gt;
        Set Label to &#039;Send&#039;&lt;br /&gt;
        Set psToolTip to &amp;quot;Send the call&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
        Procedure OnClick&lt;br /&gt;
            Send MakeCall&lt;br /&gt;
        End_Procedure&lt;br /&gt;
     &lt;br /&gt;
    End_Object&lt;br /&gt;
 &lt;br /&gt;
    // The HTTP response status code (if you get a response) will be displayed&lt;br /&gt;
    // here.&lt;br /&gt;
    Object oRespStatus is a Form&lt;br /&gt;
        Set Size to 12 26&lt;br /&gt;
        Set Location to 212 320&lt;br /&gt;
        Set Label to &amp;quot;Response Status:&amp;quot;&lt;br /&gt;
        Set Label_Justification_Mode to JMode_Right&lt;br /&gt;
        Set Label_Col_Offset to 5&lt;br /&gt;
        Set Form_Datatype to 0&lt;br /&gt;
        Set peAnchors to anTopRight&lt;br /&gt;
        Set Enabled_State to False&lt;br /&gt;
        Set psToolTip to &amp;quot;The HTTP status of the response&amp;quot;&lt;br /&gt;
    End_Object&lt;br /&gt;
 &lt;br /&gt;
    // The JSON response to your call will be displayed here.&lt;br /&gt;
    Object oReceivedJSON is a cTextEdit&lt;br /&gt;
        Set Size to 128 340&lt;br /&gt;
        Set Location to 240 7&lt;br /&gt;
        Set Label to &amp;quot;Received JSON:&amp;quot;&lt;br /&gt;
        Set peAnchors to anAll&lt;br /&gt;
        Set Read_Only_State to True&lt;br /&gt;
        Set psToolTip to &amp;quot;The data returned by the call&amp;quot;&lt;br /&gt;
    End_Object&lt;br /&gt;
 &lt;br /&gt;
CD_End_Object&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default the view is set to call http://jsonplaceholder.typicode.com/posts (click that link to see the results you should get), which is a simple testing (somewhat) RESTful web service (you can use a path of &amp;quot;posts&amp;quot; - the default - &amp;quot;todos&amp;quot;, &amp;quot;comments&amp;quot;, &amp;quot;albums&amp;quot;, &amp;quot;photos&amp;quot; or &amp;quot;users&amp;quot;, and use POST, PUT, PATCH and DELETE, as well as the default GET - see http://jsonplaceholder.typicode.com for all the options). It supports both HTTP and HTTPS. Calls will not change anything, but do return sensible responses. It is useful for testing.&lt;br /&gt;
&lt;br /&gt;
To test other services, simply change the inputs to what those require.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[REST]]&lt;br /&gt;
*[[RESTful Service Theory]]&lt;br /&gt;
*[[Creating RESTful Services in DataFlex]]&lt;br /&gt;
*[[A Simple RESTful Service]]&lt;br /&gt;
*[[Using the REST Library]]&lt;br /&gt;
&lt;br /&gt;
[[Category:REST]][[Category:Web Services]]&lt;/div&gt;</summary>
		<author><name>Mwpmullan</name></author>
	</entry>
</feed>