Focal Point
[CLOSED]Setting path parameters in REST synonym

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5257001086

January 04, 2016, 11:46 AM
Angelo Spaziani
[CLOSED]Setting path parameters in REST synonym
I need to set path parameters for a REST api call to select different data. The api accept path parameters not request parameters (/uri/value vs. /uri?parameter=value) Also in some cases there are multiple pages returned that i need to interate through, which is also set via the path so /uri/value/pageIndex. I've explored setting the create synonym command in the FEX but i cant get it to work right, nor do i know if thats the correct way. Any help would be appreciated.

This message has been edited. Last edited by: <Emily McAllister>,


8103
Server 2012
January 04, 2016, 02:54 PM
dhagen
The way I've done it is to use a variable in the meta-data.

For example, I've got 3 urls
http://jsonplaceholder.typicode.com/posts/1
http://jsonplaceholder.typicode.com/posts/10
http://jsonplaceholder.typicode.com/posts?userId=1  


Base URL in REST adaptor
http://jsonplaceholder.typicode.com/posts  


Master
FILENAME=SAMPLE_JSON_REST, SUFFIX=REST    , MFD_PROFILE=common/sample_json_rest_obj, $
 VARIABLE NAME=&&OBJ,  DEFAULT='1', $
  SEGMENT=M6ILO, SEGTYPE=S0, $
    FIELDNAME=__RESPONSE, USAGE=TX80L, ACTUAL=TX, ACCESS_PROPERTY=(INTERNAL), $
  SEGMENT=RESPONSE, SEGTYPE=S0, SEGSUF=JSON    , PARENT=M6ILO, POSITION=__RESPONSE, $
    FIELDNAME=JSON_DUMMY_EL, ALIAS=JSON_DUMMY_EL, USAGE=A1, ACTUAL=A1, ACCESS_PROPERTY=(INTERNAL),
      PROPERTY=ELEMENT,  $
    FIELDNAME=USERID, ALIAS=userId, USAGE=P33, ACTUAL=A33,
      REFERENCE=JSON_DUMMY_EL, PROPERTY=ELEMENT,  $
    FIELDNAME=ID, ALIAS=id, USAGE=P33, ACTUAL=A33,
      REFERENCE=JSON_DUMMY_EL, PROPERTY=ELEMENT,  $
    FIELDNAME=TITLE, ALIAS=title, USAGE=A74, ACTUAL=A74,
      REFERENCE=JSON_DUMMY_EL, PROPERTY=ELEMENT,  $
    FIELDNAME=BODY, ALIAS=body, USAGE=A158, ACTUAL=A158,
      REFERENCE=JSON_DUMMY_EL, PROPERTY=ELEMENT,  $
  


Acx
SEGNAME=M6ILO, 
  CONNECTION=SAMPLE, 
  OBJECT=&&OBJ, 
  SERVICETYPE=REST, 
  HTTPMETHOD=GET, 
  RESTRESPONSE=JSON, $  


MFD Profile (that you don't need if you set the value of &&OBJ before you run report):
-*-SET &&OBJ=10;
-SET &&OBJ='?userId=1';  


Just set the &&OBJ to the extended value that you require.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
January 05, 2016, 01:32 PM
Angelo Spaziani
Works like a charm! Thanks.


8103
Server 2012
January 05, 2016, 01:48 PM
Angelo Spaziani
Actually one other question, Have you ever dealt with calls that give the results back in pages. If so, how do you iterate through the pages to get all the results. In my instance it will tell me the total number of pages and total records, which i could use to create a loop but im thinking there might be a better way?


8103
Server 2012