3

I'm using APEX 21.1 and have created a REST Data Source for a web service that returns a response in the following format:

[
  [
    1499040000000,      // A time stamp
    "0.01634790",       // A value
    .... etc.
  ],
  [
    1499040000100,      // A time stamp
    "0.01634799",       // A value
    .... etc.
  ]
]

The auto-discover function complains about not finding a row selector. How do I manually set up a data profile for such a type of response?

Thanks, Ruud

1 Answer 1

4

Since this JSON structure is just a nested array, APEX cannot auto-discover that Data Profile. You can get it working as follows:

  • In the Create REST Source Wizard, use the "Create Module Manually" button
  • Edit the new REST Data Source
  • Click the Edit Data Profile button. You should see 3 pre-created columns.
  • Change the Row Selector to . (a dot)
  • Edit the first column
    • Change the column name to TIME_STAMP
    • Change the selector to [0]
    • Change the data type to NUMBER
    • Save the changes
  • Edit the second column
    • Change the column name to VALUE
    • Change the selector to [1]
    • Change the data type to VARCHAR2
    • Save the changes
  • Delete the third column
  • Save everything.

You should now be able to test the REST Data Source.

Does that help?

5
  • Many thanks Carsten, It helped somewhat. I can now test the GET operation and I get data back. Unfortunately it doesn't give me any parsed data and returns only the header and the body of the request. Is there anything else you can suggest? FYI - I have also tried setting the selectors to . (dot) but that didn't make any difference. Thank again. Commented Aug 27, 2021 at 22:34
  • I just read the help text on the Row Selector which says "Nested arrays or nested XML collections are not supported". so I guess I'm out of luck :-( Would it be possible to read the response in as one string and parse the contents in PL/SQL? Thanks Commented Aug 27, 2021 at 23:08
  • Oh my <deity of choice>! How stupid. I entered 0, 1, 2 for selector instead of [0], [1], etc. as stipulated by @Carsten. It works now. Many thanks. Commented Aug 28, 2021 at 23:55
  • I have a similar scenario. Tried given fix and not worked. It is not identify tags array. How can I enable REST data source to identify tags array? {"items": [{"name": "Item 1","qty": 100,"tags": ["red", "green"],"price": 152},{"name": "Item 2","qty": 200,"tags": ["yellow","cyan"],"price": 80}]}
    – Bishan
    Commented Nov 1, 2021 at 13:37
  • In your case, "tags" is a nested array, and REST Data Sources only support one level of tags. So if "items" is your row selector, you could create one column "tag1" with the selector "tags[0]" and "tag2" with the selector "tags[1]". Another choice would be to use "tags" as the selector and "JSON Document" as the data type. Then the array will be passed to the caller (the APEX component), and you can process the JSON array there.
    – Carsten
    Commented Nov 2, 2021 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.