Updates
- added a troubleshooting section
- explained how to refresh the destination cache
What's new
Today I learned about a new cool feature that is available with SAP Business Application Studio.
It’s now possible to run
curl commands in the terminal window of SAP Business Application Studio to test the connectivity of a destination defined in your SAP Cloud Platform Sub Account.
So if you have destination called
S4H_Test in your SAP Cloud Platform (CF) sub account

You can test the access via this destination now from within SAP Business Application Studio.
For this simply open a new terminal window

And enter the following command, where you would have to replace
S4H_TEST.dest with
<your_destination>.dest in your own sub account.
curl -v -i "S4H_Test.dest/sap/opu/odata/iwfnd/catalogservice;v=2/ServiceCollection?%24top=1"
When successful as shown in the screen shot below you would get a HTTP 200 response and you would be able to have a look at all the http headers that are sent alongside with the request and that are being returned by your backend system.
user: projects $ curl -v -i "S4H_Test.dest/sap/opu/odata/iwfnd/catalogservice;v=2/ServiceCollection?%24top=1"
* Expire in 0 ms for 6 (transfer 0x55f75e9e8f50)
* Uses proxy env variable no_proxy == 'localhost,127.0.0.1,github.com,.github.com,.npmjs.org,.yarnpkg.com,npm.sap.com,.maven.apache.org'
* Uses proxy env variable http_proxy == 'http://127.0.0.1:8887'
* Trying 127.0.0.1...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x55f75e9e8f50)
* Connected to 127.0.0.1 (127.0.0.1) port 8887 (#0)
> GET http://S4H_Test.dest/sap/opu/odata/iwfnd/catalogservice;v=2/ServiceCollection?%24top=1 HTTP/1.1
> Host: S4H_Test.dest
> User-Agent: curl/7.64.0
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK

Disclaimer
The development team of SAP Business Application Studio told me that the exact syntax of the placeholder
<destination_name>.dest might be subject to changes in the future.
Though there are currently no concrete plans for such changes it cannot be ruled out.
If there are changes, I will update my blog accordingly.
Why is this important?
To see why this is an important and valuable feature we have to take a look what the
check connection button brings to the table when checking a connection from SAP Cloud Platform to an SAP ABAP backend now with SAP Business Application Studio and in the past with SAP Web IDE.
Use case 1 - System unavailable
When the system is not available the check connection button will get the following response
Failure reason: "An error of type NoStackTraceTimeout occurred during check connection!"

In case of using the new feature of testing using curl we get a much more detailed information
GET http://S4H_Test.dest/sap/opu/odata/iwfnd/catalogservice;v=2/ServiceCollection?%24top=1 HTTP/1.1
> Host: S4H_Test.dest
> User-Agent: curl/7.64.0
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 504 Gateway Timeout
HTTP/1.1 504 Gateway Timeout
Use case 2 - Wrong password in destination
When I enter a wrong password in the definition of my destination it becomes more tricky for the UI developer to find the root cause of this error.
This is because you will get the same popup when testing the destination with the check connection button as you would get it when the password is correct.
Connection to "S4H_Test" established. Response returned: "404: Not found"

When we use curl in a terminal window in SAP Business Application Studio instead we get the following response.
> GET http://S4H_Test.dest/sap/opu/odata/iwfnd/catalogservice;v=2/ServiceCollection?%24top=1 HTTP/1.1
> Host: S4H_Test.dest
> User-Agent: curl/7.64.0
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 401 Unauthorized
HTTP/1.1 401 Unauthorized
And a large response in html format
<html><head><meta http-equiv="content-type" content="text/html; charset=windows-1252"><title>Anmeldung fehlgeschlagen</title><style>body { background: #ffffff; text-align: center; width:100%; height:100%; overflow:hidd
where
“Anmeldung fehlgeschlagen” is German and means
“Login failed”
Troubleshooting
There is a cache for destinations. I ran into this issue myself and always got an error and it seemed that changes in the destination did not become active.
By running the following command in the terminal window this cache is cleared.
curl localhost:8887/reload