REST Web Service from SAP use getpostman to test first

So you want to call a REST Web Service from SAP, but you don’t know how to go about it. Well in this situation you first need to make sure it works outside of SAP and more importantly you know what your expecting it to do or what values it will return. There are so many extra layers of complexity within an SAP landscape that getting it working outside of the SAP system will actually speed up the implementation process.  

…and before we go any further if you are new to this, maybe you have heard a bit about web services, you may have seen a few working or heard people talking about WSDL’s. You may even know what one is….. Well a REST Web Service is a web service without a WSDL!!! 

GetPostman.com

So where do you start, many of you may have heard of services like SOAPUI which also tests REST web services. Most people i know involved in web services use this and like it but i found this far too complicated. I tried 2 free trials and still couldn’t get my head around it to make a simple call and see the result. I know for a fact it is a fantastic product as people that use it tell me so but for a beginner it was just too much. Then one day someone told me about getpostman.com and within 5 minutes of installing the windows client I had a web service call working… but not only that it automatically produces example working code including JavaScript and jQuery that I was able to paste directly into a HTML page and get the web service call working from there.     

Rather than talk any more i will provide you with a URL of a REST service and tell you to google getpostman download it and try and get it working. Or you can follow the below very simple steps.  

UPDATE: This is quite funny but literally, the day after I published this article Smartbear who own SOAPUI sent an email saying that they had released a web-based API testing tool that will help you quickly and easily test your SOAP and REST API’s/Web Services. Not sure if it will be any better than postman but seems to be a step in the right direction https://swagger.io/ 

and then a few weeks later I received another email saying that they had made SOAPUI simpler to use, so it was obviously not just me (well that’s what I’m telling myself anyway:-) 

Enter your text here…

Getting ready to test your first REST Web Service using postman

1

Download the Postman client

Head over to getpostman.com and download the free client which is available fro mac, windows or linux.

2

Create New request 

Once installed it’s time to create your first web service call request, so simply press the NEW button

create postman request

Then choose request 

choose new request

Enter a request name and create a new collect or choose and existing one

create postman collectionpostman collect nameSave postman collection

3

Call the REST Web Service

Now the fun stuff simply enter the REST web service URL http://gturnquist-quoters.cfapps.io/api/random into the postman and press send.

Enter web service URL

You will now see the result of the web service call. Also note the Code button….

web service call result

4

View the Webservice execution code 

Now remember that code button from the previous step, click it and you will see the implementation code to call this web service in many different development languages including JavaScript and jQuery/Ajax. If you past this into a HTML document it probably won’t work but that’s not because the code is wrong but i will get on to this next. 

view web service codeweb service code samplesWS Ajax/jQueryWS HTTP

5

Web Service call parameters

This example REST Web Service does not have any parameters but I just wanted to show you how you would add them.  i.e. The example below would be the same as calling http://gturnquist-quoters.cfapps.io/api/random?id=123

WS Call parameters

See the result of the call with the call URL parameter

result with call parameter

6

Web Service header parameters

Again this example REST web service does not require you to pass any header parameters but this is how you would usually pass any parameters such authorisation credentials. For this demo I will just pass the Content-Type = application/xml but you could also pass something like Authorisation = “OAuth ???????????….”

Pass ws header parameter

See result with WS header parameters being passed

result with header parameters

But for this example simply remove the parameters or un check them so they are ignored.

remove postman ws parametersProgress Bar

This article is the first part of a series that will teach you how to consume/use/call a web service from within your SAP system. The next step is to test that your SAP system is able to make an outbound HTTP connection and is ready for the REST Web Service Call