In this example we will see how can we consume a REST web service in PeopleSoft. Before we start we should have some basic idea on REST web service. Unlike the SOAP based web services where we have request and responses in xml form, here the request will be in form of URI (Uniform Resource Identifier) and the response can be in xml or json etc.
In REST we have four types of operations
GET – To retrieve data
POST – Update Data
PUT – Insert Data
DELETE – Delete Data
For Example:
here the parameter countrycode will vary as per the request.
So, http://services.groupkt.com/state/get/IND/all will give the list of states present in India. Similarly, http://services.groupkt.com/state/get/USA/all will list down all the states present in USA.
Other variant of this service is
There is one more input parameter in the URI stateCode. So, this URI will give details of a state identified by stateCode of country identified by countryCode
There is one more variant also, to search for a particular state in a country.
http://services.groupkt.com/state/search/IND?text=ma will list down all the states in India having text “ma” in them.
Before we go ahead, let us understand the request and response formats. We will be using PeopleTools documents technology to build the request and response messages.
In the request, we have seen that there are three types of input parameters – countryCode, stateCode and texttoSearch
So, our request document will also have three parameters of type String.
In the response, there are four parameters – country, name, abbr, capital
So, our response document will have four parameters of type String.
Steps for Implementation
- Create request and response documents
Navigate to PeopleTools → Documents → Document Builder
Add a New Value
Now, we will add three parameters to it.
Similarly, add the other two parameters also.
Validate and save the document.
Similarly, we will now create a document for the response.
As, we can see, results are under the tag “result”, we will create a document with name result to match the response.
Now, we will create another document which will include the above created document.
In this document we will insert a collection since the results are repeating.
Validate and Save the document.
- Create request and response messages
Navigate to PeopleTools → Integration Broker → Integration Setup → Messages
Add a New value
Click Add
Click Save
Similarly, add the message for response.
Click Save
- Create REST service
Navigate to PeopleTools → Integration Broker → Integration Setup → Services
Add a New Value
Save the changes.
- Create Service Operation
Open the above created service
Click on the highlighted Add button
We have three URI’s for this service
http://services.groupkt.com/state/get/{countryCode}/all
http://services.groupkt.com/state/get/{countryCode}/{stateCode}
http://services.groupkt.com/state/search/{countryCode}?text={text to search}
Save the changes.
Validate the URI’s
Click on Generate URL
Make sure that the url is correct.
Similarly, you can verify other two URL’s
- PeopleCode to invoke the REST Service Operation
We have create a simple page to invoke the operation depending on various search options.
PeopleCode
Read the response and write it into file. (In continuation to above code)
- Test the REST Web Service
Search by Country
Output File:
Search by Country and State
Output File:
Search by Country and Text
Output File:
Hi! Deepak:
ReplyDeleteThanks for sharing example.
I tried this example but getting the following error:
"An object of class Compound failed to deserialize. (2,693)"
"An error happened while trying to unpack the value of an object of the given class."
Any idea what could be wrong? I compared the PeopleCode, looks exactly like yours. I am on PT 8.55 and HCM 9.2.
Please compare the document structure and also check if you are able to access the REST URL's from you server.
ReplyDeleteThanks! Deepak.
DeleteIt was server problem. Initially, it was working so I did not think it could be server problem.
Raj
what? what server problem? can you please provide details? I'm having the exact same issue now! :(
DeleteHi Jsk and Deepak can you help with this example??
DeleteCan you help me with consuming REST web service from FCM for sending notification
ReplyDeleteI am using Google Firebase Notification service. They have provided a REST webservice URL with POST method . However the request JSON document contains a Complex Primitive . I am unable to select a Document template having Complex Primitives. Please help me with this scenario.
DeleteI just want to send data to another system using REST to insert/update the data that i send. How can i achieve this with Consumer service
ReplyDeleteI think you'll need to use a POST request to achieve this. I think this is what I'm trying to do too.
DeleteCan you please post a tutorial on how to send a POST REST to an API.
ReplyDeleteIs this data mocked or does it go to a real PS instance?
ReplyDeleteVery nice writeup btw ...
Yes.. it does.. :)
DeleteVery useful blog. Currently am working on REST API integration between PS and a third party. PS needs to consume the REST with a datetime field (syncdate) as input parameter. Here is the code snippet:
ReplyDelete&reqMsg = CreateMessage(Operation.TEST);
&docTmpl = &reqMsg.GetURIDocument();
&comTmpl = &docTmpl.DocumentElement;
&reqMsg.URIResourceIndex = 1;
&comTmpl.GetPropertyByName("syncdate").value = DateTimeToLocalizedString(&runtime,"yyyy-mm-dd HH:mm:ss");
I am getting following error :
Caught Exception: Invalid parameter passed for method: SetValue of Document Primitive: syncdate.
Any idea on how to set value of a date time document primitive?
Top .net Companies in India, Best .net Developers in India
ReplyDeleteHello there, thank you very much for this tutorial. However i'm a bit lost in as to how do I add HEADERS to the request. Can you please give us some hints on that?
ReplyDeleteHello Deepak, Need some help on PeopleSoft Consuming JSON MQ message.
ReplyDeleteWe configured JMSTARGET node and were able to establish the connection between MQ series.
But we are not able to consume the JSON message. We tried to use Non-rowset message (as Peoplesoft don't have the ability to create message out of JSON Schema, we used online tool to convert JSON to XML and then got XSD and used in non-rowset creation). And created Service operation and added Handler code. But, we are not able to consume the message as it throws "Connection manager thrown GeneralFrameworkException" error.
Then, we tried to use Document to create the message and created the Service operation but when we try to consume message, it says "Unknown JMS message Format".
Could you please let me know if there is any documentation to Consume a JSON message using Document/non-rowset method?
Thanks so much for this article. Helps a lot.
ReplyDeleteI do have a question. The REST API I am consuming in PeopleSoft is https: and everytime I invoke, it gives out error "Integration Gateway was not able to contact the external system...."
Is this because it's on https? Do I need to put the certificate of the 3rd party to PeopleSoft? Or is there other reason behind this.
Do you configure the http proxy in your web server? I think when you acces internet by proxy, you need to configure the proxy.
DeleteA few things to check
ReplyDelete1. See if IB is configured correctly.
2. The URL is accessible from the web server.
3. Yes, if the url is having https then you may need to import the certificate to your web server.
Hi, Deepak
ReplyDeleteI need to do REST API between PeopleSoft CRM and HP ALM (Application Lifecycle Management)? I am using Document builder in CRM outbound and I need help on setup on IB Routing setup.
ALM site admin gave me URL, API Key Name, Client ID and Secret.
Please help.
Thanks,
Hi Deepak,
ReplyDeleteI am trying to hide the object label of my child document but it doesnt seem to work. Any ideas on this?
Thanks!
Hi Deepak,
ReplyDeleteHow do we use API Key when we request to third party in PeopleSoft?
Thanks!
Hi,
ReplyDeleteWe have designed an Get API where we are providing the client with a list of dates. The current format is shown below:
"minimumEffectiveDate": "2018-03-01",
"availableDates": [
{
"date": "2018-03-02"
},
{
"date": "2018-03-03"
},
{
"date": "2018-03-04"
},
{
"date": "2018-03-07"
}
Client requires the dates to show in the following format:
"minimumEffectiveDate": "2018-03-01"
"availableDates": [
"2018-03-02"
"2018-03-03"
"2018-03-07"
]
Any recommendation how this can be achieved? Thanks in advance
Hi,
ReplyDeleteAll REST services in peoplesoft based on request PS service operations respond ? in my requirement i have to post data from PS to 3rd party URL. I am trying POST method but unsuccessful. I have a experience in REST GET and PUT in both of the above based on request from 3rd party PS will respond with some data on request. but in new requirement i have to post data without any request from 3rd party. can i achieve this in REST services ?
I have a requirement in Peoplesoft.
ReplyDeleteSend the data from PS Tables to 3rd party through REST API. I have to create an AE program to pull the data and send it to 3rd party in Jason format. I will get a response of this batch load either Success / how many records loaded..
How do I achieve it? There will not be any request. We are scheduling the job nightly.
I need some details . How many documents do I need to create?
how to create messages and service Operation.
Thanks in Advance
Ram
Hi are you able to achieve this.
DeleteEither document can be created or request data in JSON format can be constructed via the app engine peoplecode.
DeleteFailed to deserialize document for message name when usig JSON RESt POST service.
ReplyDeleteA critical question from myself.... How would a 3rd party, to whom we expose this Service Operation, know which Template they will be using? Or will the SO be smart enough to look at the parameters and know which URL to invoke??
ReplyDeleteAnother question - do have have sample App Package Peoplecode to show how the collection is populated?
ReplyDeleteThat will be extremely useful.
And if you set up the Document to refer to a Record and Fields from the Record, do you need Peoplecode to populate?
Hi deepak, some images of this post are broken. I trying to following it but can see the images. Would you mind to fix then please?
ReplyDeleteHi Deepak,
ReplyDeleteThis is an excellent article you provided. I see some of the print screens are not showing up on the post. Is it possible to get all the print screens so we can follow the example in our environment?
thanks
Dave
Thank you for sharing your blog, seems to be useful information can’t wait to dig deep!
ReplyDeleteI can't see the images on the page
ReplyDeleteHi Deepak...I am trying to create a request to a 3rd party with api key as header. Not sure how to implement this. any suggestions would be highly appreciated. Thank you.
ReplyDeleteDeepak, can you review this article pictures, some do not show up..
ReplyDeleteThanks
world777 user id
ReplyDeleteImages from the post are not visible, could you load those again?
ReplyDeleteHi Ace,
ReplyDeleteCould you please let me know whether you are able to provide api Key as authorization as I too have a similar requirement?
Thanks & regards,
mmorpg oyunlar
ReplyDeleteınstagram takipçi satin al
tiktok jeton hilesi
Tiktok Jeton Hilesi
antalya saç ekimi
İnstagram takipçi satın al
instagram takipçi satin al
Metin2 Pvp Serverlar
instagram takipçi satın al
smm panel
ReplyDeletesmm panel
İs ilanlari
İNSTAGRAM TAKİPÇİ SATIN AL
Hırdavat
Www.beyazesyateknikservisi.com.tr
Servis
Jeton Hile
Aswindow is the Top Organization upvc entryways makers in delhi and Supply UPVC, Top of the line Entryways and Windows to Clients All around The Noida, Delhi Gurgaon and NCR. AS Window is a trailblazer in the creation of plasticized upvc window suppliers in gurugram and entryways. UPVC is a superb option in contrast to wood and metal. AS Window offers an extensive variety of wonderful and perfect home window plans that won't just change your home yet will likewise safeguard it from the rest of the world. UPVC is an all-climate, harmless to the ecosystem, intensity and commotion safe material for entryways and windows that add solace, accommodation, and style to current homes.
ReplyDeleteI am not able to get the images on this post. Can anyone confirm?
ReplyDelete