Question How to Post from AJAX and GET-VALUE in WEBSPEED API

BoltCutter

New Member
Hello,

We are running Progress 11.7.4 and until recently, we had a lot of WEBSPEED embedded with our html, but have since removed all of that WEBSPEED and placed this solely into our APIs. To add to the complexity, we have also started using NodeJS as our back channel for serving our website and performing OKTA Open ID Connect and PKCE OAuth 2.0 Code Flow to reasonably secure our API calls. Our AJAX GET calls are working great, but we are not having success with AJAX POST calls. The GET-VALUE() in the post API does not have any data.

One final bit of complexity.
Our Website is hosted on Server#1. NodeJS runs on this server as well.
Server 2 hosts our Webspeed and APIs.
When an API is called it is sent to a port that NodeJs is listening on, Node re-routes the API call to Server#2.
Server#2 returns a h-t-t-p response back to NodeJs, which re-routes it back to Server 1's ajax callback code. A typical AJAX GET function might look something like this.

Code:
Code:
/*
** Displays in Product Description after a quicksearch,
**  or entering qty at Parts Table.
*/
function getSinglePartAjax( cb ) {

  var api  = fmp.apiBaseUrl + "getstock/";
  var str1 = "UserName=" + enURI( fmp.apiUserName ) + "&UserID=" + enURI( fmp.apiUserID ) +
              "&part=" + enURI(fmp.apiPart) + "&qty=" + fmp.apiQty;

  $.ajax({
      url   : api,
      data  : str1,
      headers: {"x-auth-header": localStorage.getItem("access_token")},
      type  : 'GET'
  })
  .done( function(data, status, xhr) {
      if ( parseAjaxSinglePart(data) ){
        cb();
      }
  })
  .fail( function( jqXHR, textStatus, errorThrown ) {
      toastWarning( AJAX_ERROR_3 );
  });    
}
I have a single AJAX POST. too big in it's entirety to post here. I am hoping that one of our forum members can confirm that they have a post working using jQuery or vanilla JS to call their API and able to retrieve it from their API using GET-VALUE.
 
Last edited:

Stefan

Active Member
We use jQuery AJAX POST calls to WebSpeed, the message comes in as WEB-CONTEXT:X-DOCUMENT.
 

BoltCutter

New Member
We use jQuery AJAX POST calls to WebSpeed, the message comes in as WEB-CONTEXT:X-DOCUMENT.
How are you sending your post data? JSON format? XML? QueryString?. Any chance you can post a code snippet of your ajax post? What version of Progress ABL do you use?
 

Stefan

Active Member
If it's coming in on X-DOCUMENT then it's XML, we also have JSON data coming in on WEB-CONTEXT. Data format is detected by WEB-CONTEXT:IS-XML / WEB-CONTEXT:IS-JSON

We are currently on 11.7.5 / 12.2 but we have been using this pattern since 9.1.

A stripped jQuery post:

Code:
$.ajax({
    url: baseurl + "service.p",
    complete: complete,
    type: "POST",
    data: someobject.getXMLText(),
    contentType: "text/xml",
    dataType: "text",
    async: true
});
 
Top