Discussion
StaidLogic
US
Last activity: 4 Oct 2018 11:08 EDT
Unable to Construct JSON format
Hi,
I successfully consume the REST end point uRL in Pega 7.1.7 and followed the below steps and I need to pass to request as JSON and will receive response from external.
Step 1) Enter the REST URL
Step 2) Define parameters as per REST URL say I have 4 and selected Is Parameter option as True.
Step 3) Selecting the Method as POST.
Step 4) Generated Records and I feel its created much less
For example I have below sample request message after generate I didnt see the Mappings (ProcessDate) from Header and Application from BODY etcc.., generated
{
"Request": {
"HEADER": {
"ProcessDate": "String"
},
"BODY": {
"Application": {
"EmailID": "String"
},
"Miscellaneous": "text"
}
}
}
How we will map request and call CONNECT-REST ?
**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.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
CA
I have few questions for you.
1) Have you used the REST wizard to generate the rules?
2) Have you provided this sample JSON at the time of rule generation? There are two ways to do this. Either you upload this sample by clicking the Configure button next to POST method or you run a test by clicking the Test button and saving the response you obtained.
3) Can you provide screenshots of the mappings on your Connect REST rule?
StaidLogic
US
Yes through wizard only generated REST rule.
Yes provided sample JSON Request Message and applied TEST but giving error saying connection refused and its due to some fire wall issue but I proceed to generated rules.
Pegasystems Inc.
CA
If you don't upload the sample request/response via the Configure button or you don't 'save' the data after doing a 'test', classes and properties corresponding to your JSON cannot/will not be generated. If the test does not work due to firewall issues, please upload your sample JSON request via the Configure button. Your rules will then get generated as expected.
StaidLogic
US
Thanks Praneeth and now I am able to see the request and response Mappings generated.
Coforge
US
Hi,
I want to integrate with Twitter Search API (https://api.twitter.com/1.1/search/tweets.json), in CPM FW PRPC OOB have some REST-connectors readily available for use for other twitter API's but not for search.
I followed REST connector wizard,
Step1: Enter URL --> https://api.twitter.com/1.1/search/tweets.json
Step2: Define Paramaters --> In QUERY STRING PARAMETER I added 1 parameter "q" ( this is mandatory as per https://dev.twitter.com/rest/tools/console API help guide)
Step3: Select Methods --> I slected GET and click Configure and uploaded example response JSON file in Response tab.
Step4: When i click test and pass q paramter value and select proper OAuth Clinet in Authentication tab (this OAuth Clinet is working fine for other twitter API's which is OOB in PRPC) and click test i am getting "
Hi,
I want to integrate with Twitter Search API (https://api.twitter.com/1.1/search/tweets.json), in CPM FW PRPC OOB have some REST-connectors readily available for use for other twitter API's but not for search.
I followed REST connector wizard,
Step1: Enter URL --> https://api.twitter.com/1.1/search/tweets.json
Step2: Define Paramaters --> In QUERY STRING PARAMETER I added 1 parameter "q" ( this is mandatory as per https://dev.twitter.com/rest/tools/console API help guide)
Step3: Select Methods --> I slected GET and click Configure and uploaded example response JSON file in Response tab.
Step4: When i click test and pass q paramter value and select proper OAuth Clinet in Authentication tab (this OAuth Clinet is working fine for other twitter API's which is OOB in PRPC) and click test i am getting "
Pegasystems Inc.
CA
You cannot use REST wizard to test OAuth protected endpoints. The wizard only supports Basic and NTLM authentication schemes. Since you've already uploaded a sample JSON file that would help in generating Pega data model for you, there really is no need for you to test the endpoint from the wizard. When the connector is generated, manually associate an authentication profile pointing to your OAuth client instance. With this, your runtiime should work fine.
Coforge
US
Thanks for reply Praneeth and appricaite you are taking time to reply some of our queries. I remember earlier you replied one of my other question on REST integration. I could able to resolve my issue with your suggestion.
Now regrading above said problem,
I continued Step4 as you suggested and all rules with data clases generated. Now i am trying to calling this connector using similar approach what i followed to read my twitter timeline (working fine)... but i am getting "the server responded with an HTTP 401 code, indicating an authorization problem."
Fololowing are the activity steps,
Step1: Page-New of Connector class
Step2: Property-Set Param.EndPointURL = "https://api.twitter.com/1.1/search/tweets.json?q="+ @(Pega-IntegrationEngine:OauthUtilities).pzURLEncode(#cricket)
Thanks for reply Praneeth and appricaite you are taking time to reply some of our queries. I remember earlier you replied one of my other question on REST integration. I could able to resolve my issue with your suggestion.
Now regrading above said problem,
I continued Step4 as you suggested and all rules with data clases generated. Now i am trying to calling this connector using similar approach what i followed to read my twitter timeline (working fine)... but i am getting "the server responded with an HTTP 401 code, indicating an authorization problem."
Fololowing are the activity steps,
Step1: Page-New of Connector class
Step2: Property-Set Param.EndPointURL = "https://api.twitter.com/1.1/search/tweets.json?q="+ @(Pega-IntegrationEngine:OauthUtilities).pzURLEncode(#cricket)
Step3: Call PegaSocial-FW-Twitter.TwitterAuthorizedTokenHeader activity passing proper parameters, this activity construct authorization token and set to to .AuthorizationHeader property
Step4: Call Connect-REST method by passing endpoint URL as set earlier with method name GET
Note: Connect-REST genearted by wizard, in requet tab Authorization header was not set, i set it as similar to PegaSocial-FW-Twitter • SearchTweets OOB Connect-Rest.
That's it. now if i run activity i get authorization problem. Not sure what i am doing wrong.. Please help.
Pegasystems Inc.
CA
You don't have to set Authorization header explicitly. We do that automatically. Please ensure you are following these steps:
1. Create an OAuth client data record. Select Twitter from the Provider dropdown, enter values for your twitter application's consumer key and shared secret. Save the rule.
2. You first need to obtain access token before calling the search tweets API. For this, you will have to call OOTB activity pyConnectSocialNetwork passing the OAuth client instance you created in the first step as parameter. This does the entire OAuth dance and you should finally get the access token.
3. Create an authentication profile, select the type as OAuth and tag the OAuth client instance you created in step 1.
4. On you search tweets REST connector, enable authentication and select the authentication profile you created in step 3.
5. Invoke your connector like you normally do. You don't have to set Authorization header explicitly. When we detect that the authentication type on the authentication profile rule form is OAuth, we construct and add the authorization header.
Coforge
US
It worked like a charm ..!!! You are the man.... Hats off... and thanks a lot Praneeth....
IN
Tata Consultancy Services
GB