Visual Builder

Get Involved. Join the Conversation.

Topic

    Shane Lynn
    Calling a REST Service to POST data to
    Topic posted November 23, 2017 by Shane LynnRed Ribbon: 250+ Points, last edited November 29, 2017 
    101 Views, 1 Comment
    Title:
    Calling a REST Service to POST data to
    Summary:
    Calling a REST Service to POST data to
    Content:

    We have the following requirement in Visual Builder :

    * Users will enter data into Visual Builder forms and this will be saved in Business Objects.

    * Once a user is happy with hat is entered they will click a button and an External REST service will be called to POST data into. 

    * The REST Service will return a success or failure which will be displayed to the user in Visual Builder.

    My question is how do we call an External REST service to POST data into.  I have seen examples of calling REST Service to return data using getJSON but not for Posting of data.

    Additionally how do we pass through authentication to the REST Service?

    Thanks

    Shane

    Comment

     

    • Danny Treffene

      Hi Shane,

      I've found that when you call the REST service on say a button click event you can define the Parameters for mapping (in addition to Input Parameters). 

      Specifically under Parameters you should see a "{} body" option to map.

      When you click on body{} you will see a text box at the bottom under "Expression for: body".  I pasted the POST requests expected body here which in my case includes not only the data to process but the authentication details as well.  (I'm assuming you need to do the same otherwise there is a tab for Authentication when you set up the endpoint.  I'm assume you can also use any page variables you've defined in VBCS to substitute into your body structure as well but I'm yet to test this.

      Cheers,

      Danny

       

      POST.jpg (151KB)