Classic / Pacific REST removing outer response block

Posted by carl.williams on 11-Apr-2016 09:44

Is it possible to create a response without the outer response block and without opcOut which is a longchar? If I was working with a dataset I could user the "no outer block" option with write-json likewise I would not mind using a JSON Object and passing this as the response. I know I could use the new webspeed features to support REST but I wondered if it were possible with REST outside of webspeed?

Thanks in advance. 

{
  "response": {
    "opcOut": {
      "products": [
        {
          "Product": "1",
          "Description": "Hello world!"
        },
        {
          "Product": "100000",
          "Description": "Chicken Nuggets (2 lb)"
        },

becomes:

{
 [
        {
          "Product": "1",
          "Description": "Hello world!"
        },
        {
          "Product": "100000",
          "Description": "Chicken Nuggets (2 lb)"
        }

]}

PROCEDURE action:

DEFINE INPUT PARAMETER ipcAction AS CHARACTER NO-UNDO.

DEFINE INPUT PARAMETER ipcIn AS LONGCHAR NO-UNDO.

DEFINE OUTPUT PARAMETER opcOut AS LONGCHAR NO-UNDO.

DEFINE OUTPUT PARAMETER opiResponse AS INTEGER NO-UNDO INIT 200.

Posted by egarcia on 11-Apr-2016 11:03

Hello,

Yes, it is possible using the REST URI Resource Editor.

You should be able to just map to the body of the response.

In that way, you would get the actual value of opcOut instead of the response object which is used when mapping to parameter.

See the following article for a screenshot showing how the mapping looks like:

   community.progress.com/.../2190

I hope this helps.

All Replies

Posted by egarcia on 11-Apr-2016 11:03

Hello,

Yes, it is possible using the REST URI Resource Editor.

You should be able to just map to the body of the response.

In that way, you would get the actual value of opcOut instead of the response object which is used when mapping to parameter.

See the following article for a screenshot showing how the mapping looks like:

   community.progress.com/.../2190

I hope this helps.

Posted by carl.williams on 12-Apr-2016 05:23

Many thanks I had not realised you could connect to the body rather than just below it. Many thanks.

This thread is closed