Question

Configure service rest and send out pagelist data in json format as response.

Hi Team,

I have a requirement where client will be invoking the service rest held in pega, we take request ,fetch the results from db on a pagelist say ResultPage.pxResults and send this pagelist data out as a JSON response. 

Can any one let me know in detail how to convert pagelist data into JSON format.

Also for configuring service rest do i need to create any data mapping rules or class.. Please help.

Thanks In Advance.

Saba

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Correct Answer
December 11, 2016 - 5:43pm

Hi Saba,

Before introducing new Rule-Service-Rest rule in your application, you need to identify the following things
1.Define the Service package rule for Rule-Service-Rest
2.Identify whether your service package should be Stateful or Stateless in processing mode
3.Does it requires Authentication ?
4.If yes, define new Authentication Service
5.Define the pooling parameters in the Service package

Once, your service package is ready, then define Rule-Service-Rest rule

In service rest rule, identify the following things

1. Define new class structure in primage page context in Service tab.
2. Define the new page name in the service tab
3. Identify the Execution mode whether it should be Synchronously or Asynchronously.
4. In methods tab, identify which method would like to be invoked (GET,POST,PUT or DELETE)
5. Define your service activity in the methods
6. In Request and respone, identify the attribute which are needed.
7. In response option, define the Map from as JSON and mention your page structure pagelist in MapFromKey. Service rest automatically converts the pagelist into JSON object.

Cheers,
Naren

Comments

Keep up to date on this post and subscribe to comments

December 11, 2016 - 5:43pm

Hi Saba,

Before introducing new Rule-Service-Rest rule in your application, you need to identify the following things
1.Define the Service package rule for Rule-Service-Rest
2.Identify whether your service package should be Stateful or Stateless in processing mode
3.Does it requires Authentication ?
4.If yes, define new Authentication Service
5.Define the pooling parameters in the Service package

Once, your service package is ready, then define Rule-Service-Rest rule

In service rest rule, identify the following things

1. Define new class structure in primage page context in Service tab.
2. Define the new page name in the service tab
3. Identify the Execution mode whether it should be Synchronously or Asynchronously.
4. In methods tab, identify which method would like to be invoked (GET,POST,PUT or DELETE)
5. Define your service activity in the methods
6. In Request and respone, identify the attribute which are needed.
7. In response option, define the Map from as JSON and mention your page structure pagelist in MapFromKey. Service rest automatically converts the pagelist into JSON object.

Cheers,
Naren

December 12, 2016 - 2:36am
Response to Naren_Incessant

Hi Naren,

Thanks for the quick reply.. With the detailed steps you have provided i was able to configure the service rest.

I have one more question can i send multiple responses at a time. Like i have two pagelists mapped to two different classes and i need to send both as json response.

Thanks,

Saba

December 30, 2016 - 1:39am
Response to sabaf985

Hi

I have a similar requirement. There are nested page lists properties. How should we map it to the response DT