Business Logic Rest Api

I am trying to understand business logic in rest api like how to create the service and all.

I have successfully completed the documentation.

Though, I have one doubt, We send data like service name, method name and parameters through URL I want to send using data.

Eg: curl -X POST http://localhost:8080/rest/services/sample_OrderService/squareOf?num=12 -H "Authorization: Bearer " -d “{“service”:“sample_OrderService”,“method”:“squareOf”,“num”:12}”

But I am getting error as “server error” for the above example. How can I achieve that.

Update :

New Command is :
POST http://localhost:8080/rest/services/ -H “Authorization: Bearer RRtGcTPBC9X1RA11-pyOGRd_mDg”

then a message appears to input the data.
message is : Please enter content (application/x-www-form-urlencoded) to be POSTed:

Getting Response :
{“timestamp”:“2022-06-09T12:37:35.134+00:00”,“status”:405,“error”:“Method Not Allowed”,“path”:"/rest/services/"}

I am not understanding why it is not allowing post method.

Update 2.0 :
Now the following curl command is working (All I needed to do was add attribute httpMethod in method tag inside rest-services.xml file with value ‘post’) :
POST http://localhost:8080/rest/services/sample_OrderService/squareOf -H “Authorization: Be e8JASONwfR_LHNcodQrds12vIjs” -H “Content-Type: application/json”

Please enter content (application/x-www-form-urlencoded) to be POSTed:
{“num”:“12”}

But I still want to enter service name and method name in json. Is it possible ?

1 Like

No, the generic services API has predefined URL structure.

But you can easily create your own Spring MVC controllers for calling services, see Custom Controller section.